Class OceanusDateFormatter
java.lang.Object
io.github.tonywasher.joceanus.oceanus.date.OceanusDateFormatter
- All Implemented Interfaces:
OceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>
public class OceanusDateFormatter
extends Object
implements OceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>
Formatter for Date objects.
- Author:
- Tony Washer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformatDate(OceanusDate pDate) Format a Date.formatDateRange(OceanusDateRange pRange) Format a DateRange.formatLocalDate(LocalDate pDate) Format a local Date.fromBytes(byte[] pBuffer) Parse a byte array representation of a date.Obtain registration object for listeners.Obtain the locale./** Parse Date.parseDateBase(String pValue, int pBaseYear) Parse Date using the passed year as base date.parseLocalDate(String pValue) Parse LocalDate.final voidSet the date format.final voidSet the locale.byte[]toBytes(OceanusDate pDate) Create a byte array representation of a date.
-
Field Details
-
BYTE_LEN
public static final int BYTE_LENDate Byte length.- See Also:
-
-
Constructor Details
-
OceanusDateFormatter
public OceanusDateFormatter()Constructor. -
OceanusDateFormatter
Constructor.- Parameters:
pLocale- the locale
-
-
Method Details
-
getEventRegistrar
Description copied from interface:OceanusEventRegistrar.OceanusEventProviderObtain registration object for listeners.- Specified by:
getEventRegistrarin interfaceOceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>- Returns:
- the registrar
-
setFormat
Set the date format.- Parameters:
pFormat- the format string
-
setLocale
Set the locale.- Parameters:
pLocale- the locale
-
formatLocalDate
Format a local Date.- Parameters:
pDate- the date to format- Returns:
- the formatted date
-
formatDate
Format a Date.- Parameters:
pDate- the date to format- Returns:
- the formatted date
-
formatDateRange
Format a DateRange.- Parameters:
pRange- the range to format- Returns:
- the formatted date
-
parseLocalDate
Parse LocalDate.- Parameters:
pValue- Formatted Date- Returns:
- the Date
- Throws:
IllegalArgumentException- on error
-
parseDate
/** Parse Date.- Parameters:
pValue- Formatted Date- Returns:
- the DateDay
- Throws:
IllegalArgumentException- on error
-
parseDateBase
Parse Date using the passed year as base date.This is used when a two digit year is utilised
- Parameters:
pValue- Formatted DateDaypBaseYear- the base year- Returns:
- the DateDay
- Throws:
IllegalArgumentException- on error
-
getLocale
Obtain the locale.- Returns:
- the locale
-
toBytes
Create a byte array representation of a date.- Parameters:
pDate- the date to process- Returns:
- the processed date
-
fromBytes
Parse a byte array representation of a date.- Parameters:
pBuffer- the byte representation- Returns:
- the date
-