Package org.dellroad.stuff.string
Class DateEncoder
java.lang.Object
org.dellroad.stuff.string.DateEncoder
Encodes
Date
objects to and from strings.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Date
Decode the given date.static String
Encode the given date as a string of the form2009-12-01T15:33:07.763Z
.static SimpleDateFormat
getDateFormat
(String format) Get aSimpleDateFormat
configured 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
- ifdate
isnull
-
decode
Decode the given date.- Parameters:
string
- encoded date- Returns:
- decoded date
- Throws:
IllegalArgumentException
- ifstring
is malformedNullPointerException
- ifstring
isnull
-
getDateFormat
Get aSimpleDateFormat
configured with the given format and for the UTC time zone and strict parsing.- Parameters:
format
- date format string- Returns:
- date formatter
-