Class DateTimeParser

java.lang.Object
io.nosqlbench.virtdata.library.basics.shared.from_string.to_epoch.DateTimeParser
All Implemented Interfaces:
java.util.function.Function<java.lang.String,​org.joda.time.DateTime>

public class DateTimeParser
extends java.lang.Object
implements java.util.function.Function<java.lang.String,​org.joda.time.DateTime>
This function will parse a String containing a formatted date time, yielding a DateTime object. If no arguments are provided, then the format is set to
yyyy-MM-dd HH:mm:ss.SSSZ
. For details on formatting options, see @see DateTimeFormat
  • Constructor Summary

    Constructors 
    Constructor Description
    DateTimeParser()
    Initialize the parser with the default pattern of
    DateTimeParser​(java.lang.String dateTimePattern)
    Initialize the parser with the given pattern.
    DateTimeParser​(java.lang.String dateTimePattern, java.lang.String defaultTime)
    Initialize the parser with the given pattern and default value.
  • Method Summary

    Modifier and Type Method Description
    org.joda.time.DateTime apply​(java.lang.String formattedDateTime)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Constructor Details

    • DateTimeParser

      public DateTimeParser()
      Initialize the parser with the default pattern of
      yyyy-MM-dd HH:mm:ss.SSSZ
      .
    • DateTimeParser

      public DateTimeParser​(java.lang.String dateTimePattern)
      Initialize the parser with the given pattern. With this form, if any input fails to parse, or is null or empty, then an exception is thrown.
      Parameters:
      dateTimePattern - The pattern which represents the incoming format.
    • DateTimeParser

      public DateTimeParser​(java.lang.String dateTimePattern, java.lang.String defaultTime)
      Initialize the parser with the given pattern and default value. In this form, if any input fails to parse, then exceptions are suppressed and the default is provided instead. At initialization, the default is parsed as a sanity check.
      Parameters:
      dateTimePattern - The pattern which represents the incoming format.
      defaultTime - An example of a formatted datetime string which is used as a default.
  • Method Details

    • apply

      public org.joda.time.DateTime apply​(java.lang.String formattedDateTime)
      Specified by:
      apply in interface java.util.function.Function<java.lang.String,​org.joda.time.DateTime>