Package org.dellroad.stuff.string
Class DateEncoder
java.lang.Object
org.dellroad.stuff.string.DateEncoder
Encodes
Date objects to and from strings.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DateDecode the given date.static StringEncode the given date as a string of the form2009-12-01T15:33:07.763Z.static SimpleDateFormatgetDateFormat(String format) Get aSimpleDateFormatconfigured with the given format and for the UTC time zone and strict parsing.
-
Field Details
-
PATTERN
Regular expression matching properly encoded strings.- See Also:
-
-
Method Details
-
encode
Encode the given date as a string of the form2009-12-01T15:33:07.763Z. If the fractional seconds portion is zero, it will be omitted.- Parameters:
date- date to encode- Returns:
- endoded date
- Throws:
NullPointerException- ifdateisnull
-
decode
Decode the given date.- Parameters:
string- encoded date- Returns:
- decoded date
- Throws:
IllegalArgumentException- ifstringis malformedNullPointerException- ifstringisnull
-
getDateFormat
Get aSimpleDateFormatconfigured with the given format and for the UTC time zone and strict parsing.- Parameters:
format- date format string- Returns:
- date formatter
-