public class JodaDateFormatter extends Object implements DateFormatter
Modifier and Type | Field and Description |
---|---|
org.joda.time.format.DateTimeFormatter |
parser |
org.joda.time.format.DateTimeFormatter |
printer |
Constructor and Description |
---|
JodaDateFormatter(String pattern,
org.joda.time.format.DateTimeFormatter parser,
org.joda.time.format.DateTimeFormatter printer) |
Modifier and Type | Method and Description |
---|---|
String |
format(TemporalAccessor accessor)
Print the supplied java time accessor in a string based representation according to this formatter
|
String |
formatJoda(org.joda.time.DateTime dateTime) |
String |
formatMillis(long millis)
Return the given millis-since-epoch formatted with this format.
|
Locale |
locale()
Returns the configured locale of the date formatter
|
TemporalAccessor |
parse(String input)
Try to parse input to a java time TemporalAccessor using joda-time library.
|
org.joda.time.DateTime |
parseJoda(String input)
Parse the given input into a Joda
DateTime . |
long |
parseMillis(String input) |
String |
pattern()
A name based format for this formatter.
|
JodaDateMathParser |
toDateMathParser()
Return a
DateMathParser built from this formatter. |
DateFormatter |
withLocale(Locale locale)
Create a copy of this formatter that is configured to parse dates in the specified locale
|
JodaDateFormatter |
withYear(int year) |
DateFormatter |
withZone(ZoneId zoneId)
Create a copy of this formatter that is configured to parse dates in the specified time zone
|
ZoneId |
zone()
Returns the configured time zone of the date formatter
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
formatJoda, splitCombinedPatterns
public final org.joda.time.format.DateTimeFormatter parser
public final org.joda.time.format.DateTimeFormatter printer
public JodaDateFormatter(String pattern, org.joda.time.format.DateTimeFormatter parser, org.joda.time.format.DateTimeFormatter printer)
public TemporalAccessor parse(String input)
parse
in interface DateFormatter
input
- An arbitrary string resembling the string representation of a date or timeIllegalArgumentException
- if the text to parse is invalidDateTimeException
- if the parsing result exceeds the supported range
of ZoneDateTime
or if the parsed instant exceeds
the maximum or minimum instantDateFormatter.parse(String)
public long parseMillis(String input)
public org.joda.time.DateTime parseJoda(String input)
DateFormatter
DateTime
.parseJoda
in interface DateFormatter
public DateFormatter withZone(ZoneId zoneId)
DateFormatter
withZone
in interface DateFormatter
zoneId
- The time zone to act onpublic DateFormatter withLocale(Locale locale)
DateFormatter
withLocale
in interface DateFormatter
locale
- The local to use for the new formatterpublic String format(TemporalAccessor accessor)
DateFormatter
format
in interface DateFormatter
accessor
- The temporal accessor used to formatpublic String formatJoda(org.joda.time.DateTime dateTime)
public String formatMillis(long millis)
DateFormatter
formatMillis
in interface DateFormatter
public JodaDateFormatter withYear(int year)
public String pattern()
DateFormatter
epoch_millis
or
a configured format like HH:mm:ss
pattern
in interface DateFormatter
public Locale locale()
DateFormatter
locale
in interface DateFormatter
public ZoneId zone()
DateFormatter
zone
in interface DateFormatter
public JodaDateMathParser toDateMathParser()
DateFormatter
DateMathParser
built from this formatter.toDateMathParser
in interface DateFormatter
Copyright © 2022. All rights reserved.