Class ElasticsearchDateConverter

java.lang.Object
org.springframework.data.elasticsearch.core.convert.ElasticsearchDateConverter

public final class ElasticsearchDateConverter extends Object
Provides Converter instances to convert to and from Dates in the different date and time formats that elasticsearch understands.
Since:
4.0
Author:
Peter-Josef Meisch
  • Method Details

    • of

      public static ElasticsearchDateConverter of(DateFormat dateFormat)
      Creates an ElasticsearchDateConverter for the given DateFormat.
      Parameters:
      dateFormat - must not be @{literal null}
      Returns:
      converter
    • of

      public static ElasticsearchDateConverter of(String pattern)
      Creates an ElasticsearchDateConverter for the given pattern.
      Parameters:
      pattern - must not be null
      Returns:
      converter
    • format

      public String format(TemporalAccessor accessor)
      Formats the given TemporalAccessor into a String.
      Parameters:
      accessor - must not be null
      Returns:
      the formatted object
    • format

      public String format(Date date)
      Formats the given TemporalAccessor int a String
      Parameters:
      date - must not be null
      Returns:
      the formatted object
    • parse

      public <T extends TemporalAccessor> T parse(String input, Class<T> type)
      Parses a String into a TemporalAccessor.
      Type Parameters:
      T - the class of type
      Parameters:
      input - the String to parse, must not be null.
      type - the class to return
      Returns:
      the new created object
    • parse

      public Date parse(String input)
      Parses a String into a Date.
      Parameters:
      input - the String to parse, must not be null.
      Returns:
      the new created object