com.timeindexing.time
Class TimeDateParser

java.lang.Object
  extended bycom.timeindexing.time.TimeDateParser

public class TimeDateParser
extends java.lang.Object

Parses a time or date from a given input.


Field Summary
protected static DateParser dayFormat
           
protected static DateParser fullestFormat
           
protected static DateParser fullFormat
           
protected static DateParser hourFormat
           
protected static DateParser secondFormat
           
protected static DateParser ymdFormat
           
 
Constructor Summary
TimeDateParser()
          Construct a TimeDateParser.
 
Method Summary
protected  Timestamp createTimestamp(long seconds, int subSeconds, int subSecondLen, boolean absolute)
          Create a Timestamp given some seconds, some subSeconds, the length of the original subSecond string, and whether to create an absolute or relative Timestamp.
 Timestamp parse(java.lang.String timeArg, boolean absolute)
          Parse timestamps given as a String.
 Timestamp parse(java.lang.String timeArg, boolean absolute, java.lang.String parseFormat)
          Parse timestamps given as a String.
protected  int parseSubseconds(java.lang.String subSecondStr)
          Parse the subsecond part of a time String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fullestFormat

protected static DateParser fullestFormat

fullFormat

protected static DateParser fullFormat

ymdFormat

protected static DateParser ymdFormat

dayFormat

protected static DateParser dayFormat

hourFormat

protected static DateParser hourFormat

secondFormat

protected static DateParser secondFormat
Constructor Detail

TimeDateParser

public TimeDateParser()
Construct a TimeDateParser.

Method Detail

parse

public Timestamp parse(java.lang.String timeArg,
                       boolean absolute)
Parse timestamps given as a String. Absolute or relative timestamps can be specified.

The timestamps are of the format "time.subseconds" Formats processed for time are:

The returned Timestamp is at a resolution based on the resolution of the passed in string. Formats for subseconds can resolve down to nanoseconds. e.g. .2 is 2/10ths of a seconds, .200 is 200 milliseconds, .25000 is 25000 microseconds, and so on.

Parameters:
absolute - should the timestamp be parsed as an absolute time or a relative time.
Returns:
a Timestamp object if the input is valid, null otherwise.

parse

public Timestamp parse(java.lang.String timeArg,
                       boolean absolute,
                       java.lang.String parseFormat)
Parse timestamps given as a String. Absolute or relative timestamps can be specified. The parse format also has to be specified.

The timestamps are of the format "time.subseconds" Formats processed for time are those supported by java.text.SimpleDateFormat.parse().

The returned Timestamp is at a resolution based on the resolution of the passed in string. Formats for subseconds can resolve down to nanoseconds. e.g. .2 is 2/10ths of a seconds, .200 is 200 milliseconds, .25000 is 25000 microseconds, and so on.

Parameters:
absolute - should the timestamp be parsed as an absolute time or a relative time.
Returns:
a Timestamp object if the input is valid, null otherwise.

parseSubseconds

protected int parseSubseconds(java.lang.String subSecondStr)
Parse the subsecond part of a time String.

Returns:
the number seconds.

createTimestamp

protected Timestamp createTimestamp(long seconds,
                                    int subSeconds,
                                    int subSecondLen,
                                    boolean absolute)
Create a Timestamp given some seconds, some subSeconds, the length of the original subSecond string, and whether to create an absolute or relative Timestamp.