Package org.elasticsearch.common.joda
Class JodaDateFormatter
- java.lang.Object
-
- org.elasticsearch.common.joda.JodaDateFormatter
-
- All Implemented Interfaces:
DateFormatter
public class JodaDateFormatter extends java.lang.Object implements DateFormatter
-
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.Stringformat(java.time.temporal.TemporalAccessor accessor)Print the supplied java time accessor in a string based representation according to this formatterjava.lang.StringformatJoda(org.joda.time.DateTime dateTime)Return the given JodaDateTimeformatted with this format.java.lang.StringformatMillis(long millis)Return the given millis-since-epoch formatted with this format.inthashCode()java.util.Localelocale()Returns the configured locale of the date formatterjava.time.temporal.TemporalAccessorparse(java.lang.String input)Try to parse input to a java time TemporalAccessororg.joda.time.DateTimeparseJoda(java.lang.String input)Parse the given input into a JodaDateTime.longparseMillis(java.lang.String input)Parse the given input into millis-since-epoch.java.lang.Stringpattern()A name based format for this formatter.DateMathParsertoDateMathParser()Create a DateMathParser from the existing formatterDateFormatterwithLocale(java.util.Locale locale)Create a copy of this formatter that is configured to parse dates in the specified localeJodaDateFormatterwithYear(int year)DateFormatterwithZone(java.time.ZoneId zoneId)Create a copy of this formatter that is configured to parse dates in the specified time zonejava.time.ZoneIdzone()Returns the configured time zone of the date formatter
-
-
-
Method Detail
-
parse
public java.time.temporal.TemporalAccessor parse(java.lang.String input)
Description copied from interface:DateFormatterTry to parse input to a java time TemporalAccessor- Specified by:
parsein interfaceDateFormatter- Parameters:
input- An arbitrary string resembling the string representation of a date or time- Returns:
- The java time object containing the parsed input
-
parseMillis
public long parseMillis(java.lang.String input)
Description copied from interface:DateFormatterParse the given input into millis-since-epoch.- Specified by:
parseMillisin interfaceDateFormatter
-
parseJoda
public org.joda.time.DateTime parseJoda(java.lang.String input)
Description copied from interface:DateFormatterParse the given input into a JodaDateTime.- Specified by:
parseJodain interfaceDateFormatter
-
withZone
public DateFormatter withZone(java.time.ZoneId zoneId)
Description copied from interface:DateFormatterCreate a copy of this formatter that is configured to parse dates in the specified time zone- Specified by:
withZonein interfaceDateFormatter- Parameters:
zoneId- The time zone to act on- Returns:
- A copy of the date formatter this has been called on
-
withLocale
public DateFormatter withLocale(java.util.Locale locale)
Description copied from interface:DateFormatterCreate a copy of this formatter that is configured to parse dates in the specified locale- Specified by:
withLocalein interfaceDateFormatter- Parameters:
locale- The local to use for the new formatter- Returns:
- A copy of the date formatter this has been called on
-
format
public java.lang.String format(java.time.temporal.TemporalAccessor accessor)
Description copied from interface:DateFormatterPrint the supplied java time accessor in a string based representation according to this formatter- Specified by:
formatin interfaceDateFormatter- Parameters:
accessor- The temporal accessor used to format- Returns:
- The string result for the formatting
-
formatJoda
public java.lang.String formatJoda(org.joda.time.DateTime dateTime)
Description copied from interface:DateFormatterReturn the given JodaDateTimeformatted with this format.- Specified by:
formatJodain interfaceDateFormatter
-
formatMillis
public java.lang.String formatMillis(long millis)
Description copied from interface:DateFormatterReturn the given millis-since-epoch formatted with this format.- Specified by:
formatMillisin interfaceDateFormatter
-
withYear
public JodaDateFormatter withYear(int year)
-
pattern
public java.lang.String pattern()
Description copied from interface:DateFormatterA name based format for this formatter. Can be one of the registered formatters likeepoch_millisor a configured format likeHH:mm:ss- Specified by:
patternin interfaceDateFormatter- Returns:
- The name of this formatter
-
locale
public java.util.Locale locale()
Description copied from interface:DateFormatterReturns the configured locale of the date formatter- Specified by:
localein interfaceDateFormatter- Returns:
- The locale of this formatter
-
zone
public java.time.ZoneId zone()
Description copied from interface:DateFormatterReturns the configured time zone of the date formatter- Specified by:
zonein interfaceDateFormatter- Returns:
- The time zone of this formatter
-
toDateMathParser
public DateMathParser toDateMathParser()
Description copied from interface:DateFormatterCreate a DateMathParser from the existing formatter- Specified by:
toDateMathParserin interfaceDateFormatter- Returns:
- The DateMathParser object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-