The datefmt
package contains the formatting implementations related to dates. In
general, these utilities should always be used via static reference if one is available.
Date values are constrained as follows:
- Two-digit year dates must represent dates between 1944 and 2043
- Four-digit year dates must represent dates between 1600 and 2299
- One-digit year dates must represent dates in the years between -4 and +5 years from the
current date. For example, if the current day was 1 November 2000, only 1 January 1996 through
31 December 2005 would be permitted
When a time is coerced into a date, the number of hours in the time is treated as the number
of days since the minimum valid date; minutes and seconds are discarded. When a number is
coerced into a date, the integer portion is treated as the number of days since the minimum
valid date less one; fractional content is discarded.
Chart shows date format names, a description, presentation, and the raw pattern used.
Format Reference |
Description |
Default Presentation of April 28th, 2012 |
Format Pattern |
Date0 |
Presents input in a date format |
50428 |
yMMdd |
Date1 |
Presents input in a date format |
150428 |
yyMMdd |
Date2 |
Presents input in a date format; spaces are preserved for both parsing and formatting |
28 APR 15 |
dd MMM yy |
Date3 |
Presents input in a date format based on the year and Julian day |
5118 |
yDDD |
Date4 |
Presents input in a date format based on the year and Julian day |
15118 |
yyD |
Date5 |
Presents input in a date format |
280415 |
ddMMyy |
Date6 |
Presents input in a date format |
04/28/15 |
MM/dd/yy |
Date7 |
Presents input in a date format |
APRIL 28, 2105 |
MMMMMMMMM d, yyyy |
Date8 |
Presents input in a date format |
042815 |
MMddyy |
Date9 |
Presents input in a date format |
28/04/15 |
dd/MM/yy |
Date11 |
Presents input in a date format |
20150428 |
yyyyMMdd |
Date12 |
Presents input in a date format |
28 APR 2015 |
dd MMM yyyy |
Date14 |
Presents input in a date format based on the year and Julian day |
2015118 |
yyyyDDD |
Date15 |
Presents input in a date format based |
28042015 |
ddMMyyyy |
Date16 |
Presents input in a date format |
04/28/2015 |
MM/dd/yyyy |
Date18 |
Presents input in a date format |
04282015 |
MMddyyyy |
Date19 |
Presents input in a date format |
28/04/2015 |
dd/MM/yyyy |
Date20 |
Presents input in a date format |
2015-04-28 |
yyyy-MM-dd |
DateC |
Presents input in a date format |
APRIL |
MMMMMMMMM |
DateD |
Presents input in a date format |
28 |
d |
DateJ |
Presents input in a date format |
118 |
D |
DateM |
Presents input in a date format |
4 |
M |
DateY |
Presents input in a date format |
15 |
yy |
DateZ |
Presents input in a date format |
2015 |
yyyy |
Classes and Interfaces |
CustomDateFormatBase |
Custom date format base class for all single-digit year date formats; needed since
FastDateFormat (like JDK7) returns two digits for "Y".
|
Date0Format |
Custom date format class for single-digit year date format DATE0$ (implements the pattern
YMMDD , which is also used for the @DAT format A ); needed since
FastDateFormat (like JDK7) returns two digits for "Y".
|
Date11Format |
Custom date format class for four-digit year date format DATE11$ (implements the pattern
YYYYMMDD , which is also used for the @DAT format L )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date12Format |
Custom date format class for four-digit year date format DATE12$ (implements the pattern
DD MMM YYYY , which is also used for the @DAT format M )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date14Format |
Custom date format class for four-digit year date format DATE14$ (implements the pattern
YYYYDDD , which is also used for the @DAT format O )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date15Format |
Custom date format class for four-digit year date format DATE15$ (implements the pattern
DDMMYYYY , which is also used for the @DAT format P )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date16Format |
Custom date format class for four-digit year date format DATE16$ (implements the pattern
MM/DD/YYYY , which is also used for the @DAT format Q )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date18Format |
Custom date format class for four-digit year date format DATE18$ (implements the pattern
MMDDYYYY , which is also used for the @DAT format S )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date19Format |
Custom date format class for four-digit year date format DATE19$ (implements the pattern
DD/MM/YYYY , which is also used for the @DAT format T )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date1Format |
Custom date format class for single-digit year date format DATE1$ (implements the pattern
YYMMDD , which is also used for the @DAT format B )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date20Format |
Custom date format class for four-digit year date format DATE20$ (implements the pattern
YYYY-MM-DD , which is also used for the @DAT format U )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date2Format |
Custom date format class for double-digit year date format DATE2$ (implements the pattern
DD MMM YY , which is also used for the @DAT format C )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date3Format |
Custom date format class for single-digit year date format DATE3$ (implements the pattern
YDDD , which is also used for the @DAT format D ); needed since
FastDateFormat (like JDK7) returns two digits for "Y".
|
Date4Format |
Custom date format class for double-digit year date format DATE4$ (implements the pattern
YYDDD , which is also used for the @DAT format E )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date5Format |
Custom date format class for double-digit year date format DATE5$ (implements the pattern
DDMMYY , which is also used for the @DAT format F )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date6Format |
Custom date format class for double-digit year date format DATE6$ (implements the pattern
MM/DD/YY , which is also used for the @DAT format G )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date7Format |
Custom date format class for four-digit year date format DATE7$ (implements the pattern
MONTH DD, YYYY , which is also used for the @DAT format H )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date8Format |
Custom date format class for double-digit year date format DATE8$ (implements the pattern
MMDDYY , which is also used for the @DAT format I )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
Date9Format |
Custom date format class for double-digit year date format DATE9$ (implements the pattern
DD/MM/YY , which is also used for the @DAT format J )
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat ). |
DateCFormat |
Custom date format class for the @CAL date format D(C) (implements the pattern
MONTH ).
|
DateDFormat |
Custom date format class for the @CAL date format D(D) (implements the pattern
D ).
|
DateFormatCustomizer |
Enumeration instances are used to perform custom processing and validation during date
formatting. |
DateJFormat |
Custom date format class for the @CAL date format D(J) (implements the pattern
DDD ).
|
DateMFormat |
Custom date format class for the @CAL date format D(M) (implements the pattern
M ).
|
DateNFormat |
Custom date format class for the @CAL date format D(N) (implements the pattern
DAY NUMBER ) (numerical day of week, with Sunday being 1).
|
DateWFormat |
Custom date format class for the @CAL date format D(W) (implements the pattern
DAY NAME ).
|
DateYFormat |
Custom date format class for the @CAL double-digit year date format D(Y) (implements the
pattern YY ).
|
DateZFormat |
Custom date format class for the @CAL four-digit year date format D(Z) (implements the pattern
YYYY ).
|
DecimalAcceptingDateFormatBase |
Custom date format base class for all date formats that accept values between zero and one
exclusive (the values are treated as unformatted literals).
|
Class: CustomDateFormatBase
next
package
Custom date format base class for all single-digit year date formats; needed since
FastDateFormat
(like JDK7) returns two digits for "Y".
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Ctor for initializing an instance of this class; uses default customization of the date format.
- Parameters:
aPattern - the pattern to use for formatting
protected CustomDateFormatBase(java.lang.String aPattern)
|
Ctor for initializing an instance of this class.
- Parameters:
aPattern - the pattern to use for formatting
aFormat - the format for content display
aFormatCustomizer - the customizer used for handling any non-standard or externalized formatting
protected CustomDateFormatBase(java.lang.String aPattern, com.arsi.mj.text.datefmt.DateFormatCustomizer aFormatCustomizer)
|
Ctor for initializing an instance of this class; uses default customization of the date format.
- Parameters:
aPattern - the pattern to use for formatting
aFormat - the format for content display
protected CustomDateFormatBase(java.lang.String aPattern, com.arsi.mj.text.FormatOption aFormat)
|
Ctor for initializing an instance of this class.
- Parameters:
aPattern - the pattern to use for formatting
aFormat - the format for content display
aFormatCustomizer - the customizer used for handling any non-standard or externalized formatting
protected CustomDateFormatBase(java.lang.String aPattern, com.arsi.mj.text.FormatOption aFormat, com.arsi.mj.text.datefmt.DateFormatCustomizer aFormatCustomizer)
|
Methods |
Implementation that replaces basic formatting with results from custom formatting.
- See Also:
- org.apache.commons.lang3.time.FastDateFormat#applyRules(java.util.Calendar, java.lang.StringBuffer)
protected java.lang.StringBuffer applyRules(java.util.Calendar aCalendar, java.lang.StringBuffer aBuffer)
|
Customizes the base implementation to handle the Mapper number-to-date coercion logic.
- See Also:
- org.apache.commons.lang3.time.FastDateFormat#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.StringBuffer format(java.lang.Object anObject, java.lang.StringBuffer aTargetBuffer, java.text.FieldPosition aPosition)
|
Custom date format class for single-digit year date format DATE0$ (implements the pattern
YMMDD
, which is also used for the @DAT format A
); needed since
FastDateFormat
(like JDK7) returns two digits for "Y".
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date0Format()
|
Custom date format class for four-digit year date format DATE11$ (implements the pattern
YYYYMMDD
, which is also used for the @DAT format L
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date11Format()
|
Custom date format class for four-digit year date format DATE12$ (implements the pattern
DD MMM YYYY
, which is also used for the @DAT format M
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date12Format()
|
Custom date format class for four-digit year date format DATE14$ (implements the pattern
YYYYDDD
, which is also used for the @DAT format O
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date14Format()
|
Custom date format class for four-digit year date format DATE15$ (implements the pattern
DDMMYYYY
, which is also used for the @DAT format P
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date15Format()
|
Custom date format class for four-digit year date format DATE16$ (implements the pattern
MM/DD/YYYY
, which is also used for the @DAT format Q
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date16Format()
|
Custom date format class for four-digit year date format DATE18$ (implements the pattern
MMDDYYYY
, which is also used for the @DAT format S
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date18Format()
|
Custom date format class for four-digit year date format DATE19$ (implements the pattern
DD/MM/YYYY
, which is also used for the @DAT format T
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date19Format()
|
Custom date format class for single-digit year date format DATE1$ (implements the pattern
YYMMDD
, which is also used for the @DAT format B
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date1Format()
|
Custom date format class for four-digit year date format DATE20$ (implements the pattern
YYYY-MM-DD
, which is also used for the @DAT format U
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date20Format()
|
Custom date format class for double-digit year date format DATE2$ (implements the pattern
DD MMM YY
, which is also used for the @DAT format C
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date2Format()
|
Custom date format class for single-digit year date format DATE3$ (implements the pattern
YDDD
, which is also used for the @DAT format D
); needed since
FastDateFormat
(like JDK7) returns two digits for "Y".
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date3Format()
|
Custom date format class for double-digit year date format DATE4$ (implements the pattern
YYDDD
, which is also used for the @DAT format E
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date4Format()
|
Custom date format class for double-digit year date format DATE5$ (implements the pattern
DDMMYY
, which is also used for the @DAT format F
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date5Format()
|
Custom date format class for double-digit year date format DATE6$ (implements the pattern
MM/DD/YY
, which is also used for the @DAT format G
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date6Format()
|
Custom date format class for four-digit year date format DATE7$ (implements the pattern
MONTH DD, YYYY
, which is also used for the @DAT format H
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date7Format()
|
Custom date format class for double-digit year date format DATE8$ (implements the pattern
MMDDYY
, which is also used for the @DAT format I
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date8Format()
|
Custom date format class for double-digit year date format DATE9$ (implements the pattern
DD/MM/YY
, which is also used for the @DAT format J
)
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public Date9Format()
|
Custom date format class for the @CAL date format D(C) (implements the pattern
MONTH
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateCFormat()
|
Custom date format class for the @CAL date format D(D) (implements the pattern
D
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateDFormat()
|
Enumeration instances are used to perform custom processing and validation during date
formatting.
public class com.arsi.mj.text.datefmt.DateFormatCustomizer
extends java.lang.Enum
Methods |
Customizes the default formatting transform to support custom Mapper formats.
- Parameters:
aContentSource - date source information.
aFormattedDate - date formatted using the base format.
- Returns:
- the customized result.
public abstract java.lang.String transform(java.util.Calendar aContentSource, java.lang.String aFormattedDate)
|
public static com.arsi.mj.text.datefmt.DateFormatCustomizer valueOf(java.lang.String name)
|
public static com.arsi.mj.text.datefmt.DateFormatCustomizer values()
|
Custom date format class for the @CAL date format D(J) (implements the pattern
DDD
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateJFormat()
|
Custom date format class for the @CAL date format D(M) (implements the pattern
M
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateMFormat()
|
Custom date format class for the @CAL date format D(N) (implements the pattern
DAY NUMBER
) (numerical day of week, with Sunday being 1).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateNFormat()
|
Custom date format class for the @CAL date format D(W) (implements the pattern
DAY NAME
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateWFormat()
|
Custom date format class for the @CAL double-digit year date format D(Y) (implements the
pattern YY
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateYFormat()
|
Custom date format class for the @CAL four-digit year date format D(Z) (implements the pattern
YYYY
).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Public ctor for initializing an instance of this class. public DateZFormat()
|
Class: DecimalAcceptingDateFormatBase
previous
package
Custom date format base class for all date formats that accept values between zero and one
exclusive (the values are treated as unformatted literals).
Treat this class as "thread-safe" (actually it relies on the thread safety of
FastDateFormat
).
Constructors |
Ctor for initializing an instance of this class; uses default customization of the date format.
- Parameters:
aPattern - the pattern to use for formatting
protected DecimalAcceptingDateFormatBase(java.lang.String aPattern)
|
Ctor for initializing an instance of this class.
- Parameters:
aPattern - the pattern to use for formatting
aFormatCustomizer - the customizer used for handling any non-standard or externalized formatting
protected DecimalAcceptingDateFormatBase(java.lang.String aPattern, com.arsi.mj.text.datefmt.DateFormatCustomizer aFormatCustomizer)
|
Methods |
Customizes the base implementation to handle the Mapper number-to-date coercion logic for
formats that accept fractional positive values.
- See Also:
- org.apache.commons.lang3.time.FastDateFormat#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.StringBuffer format(java.lang.Object anObject, java.lang.StringBuffer aTargetBuffer, java.text.FieldPosition aPosition)
|