Class ZonedDateTimeConversionHandler

java.lang.Object
csv.impl.csv.type.ZonedDateTimeConversionHandler
All Implemented Interfaces:
TypeConverter

public class ZonedDateTimeConversionHandler extends Object implements TypeConverter
A conversion handler for dates. The default implementation can recognize these date strings: dd/MM/yyyy, dd.MM.yyyy, dd/MM/yy, dd.MM.yy, yyyy/MM/dd, yyyy.MM.dd. Please not that for a specific date string the first suitable format will be used.
Author:
ralph
  • Field Details

  • Constructor Details

    • ZonedDateTimeConversionHandler

      public ZonedDateTimeConversionHandler()
      Constructor.
  • Method Details

    • getTypes

      public Class<?>[] getTypes()
      Returns the types that this handler is responsible for.
      Specified by:
      getTypes in interface TypeConverter
      Returns:
      type strings
    • fromStream

      public Object fromStream(Object o)
      Converts string to date. This method tries to parse the given string by checking each possible date format. If no format applies then the original string will be returned
      Specified by:
      fromStream in interface TypeConverter
      Parameters:
      s - string to be parsed
      Returns:
      date
      See Also:
    • toStream

      public Object toStream(Object o)
      Converts the date to its string representation.
      Specified by:
      toStream in interface TypeConverter
      Parameters:
      o - date to be converted
      Returns:
      string representation of date
      See Also:
    • getParsingFormatters

      public DateTimeFormatter[] getParsingFormatters()
      Returns the date formatters created from our date formatters.
      Returns:
      array of formatters to be used (never null!)
    • getParsingFormats

      public String[] getParsingFormats()
      Returns the formats that will be used. This method returns default formats when no formats were set
      Returns:
      the format strings used for parsing dates (never null!).
    • setParsingFormats

      public void setParsingFormats(String[] parsingFormats)
      Sets the parsing date formats to be used.
      Parameters:
      parsingFormats - the parsingFormats to set
    • getPrintFormat

      public String getPrintFormat()
      Returns the printing format. This method will return the first parsing format if no format was set.
      Returns:
      the printFormat
    • setPrintFormat

      public void setPrintFormat(String printFormat)
      Sets the format used for printing.
      Parameters:
      printFormat - the printFormat to set
    • getPrintFormatter

      public DateTimeFormatter getPrintFormatter()
      Returns the print formatter created from the print format.
      Returns:
      print formatter
    • setZoneId

      public void setZoneId(ZoneId zoneId)
      Sets the timezone for formatting and parsing.
      Parameters:
      zoneId - timezone to be used.
    • getZoneId

      public ZoneId getZoneId()
      Returns the timezone this handler uses.
      Returns:
      timezone