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 TypeMethodDescriptionformatCalendarDay(Calendar pDate) Format a calendar Date.formatDate(OceanusDate pDate) Format a Date.formatDateRange(OceanusDateRange pRange) Format a DateRange.formatJavaDate(Date pDate) Format a java Date.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.parseCalendarDay(String pValue) Parse CalendarDay.Parse Date.parseDateBase(String pValue, int pBaseYear) Parse Date using the passed year as base date.parseJavaDate(String pValue) Parse Java 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
-
formatCalendarDay
Format a calendar Date.- Parameters:
pDate- the date to format- Returns:
- the formatted date
-
formatLocalDate
Format a local Date.- Parameters:
pDate- the date to format- Returns:
- the formatted date
-
formatJavaDate
Format a java 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
-
parseJavaDate
Parse Java Date.- Parameters:
pValue- Formatted Date- Returns:
- the Date
- Throws:
IllegalArgumentException- on error
-
parseLocalDate
Parse LocalDate.- Parameters:
pValue- Formatted Date- Returns:
- the Date
- Throws:
IllegalArgumentException- on error
-
parseCalendarDay
Parse CalendarDay.- Parameters:
pValue- Formatted CalendarDay- Returns:
- the CalendarDay
- 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
-