com.timeindexing.time
Class TimeDateParser

java.lang.Object
  extended by com.timeindexing.time.TimeDateParser

public class TimeDateParser
extends java.lang.Object

Parses a time or date from a given input.


Field Summary
protected  DateParser dayFormat
           
protected  DateParser dmyFormat
           
protected  DateParser dmyFullestFormat
           
protected  DateParser dmyFullFormat
           
protected  DateParser fullestFormat
           
protected  DateParser fullestFormatNS
           
protected  DateParser fullFormat
           
protected  DateParser fullFormatNS
           
protected  DateParser hourFormat
           
protected  DateParser secondFormat
           
protected  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 DateParser fullestFormat

dmyFullestFormat

protected DateParser dmyFullestFormat

fullestFormatNS

protected DateParser fullestFormatNS

fullFormat

protected DateParser fullFormat

dmyFullFormat

protected DateParser dmyFullFormat

fullFormatNS

protected DateParser fullFormatNS

ymdFormat

protected DateParser ymdFormat

dmyFormat

protected DateParser dmyFormat

dayFormat

protected DateParser dayFormat

hourFormat

protected DateParser hourFormat

secondFormat

protected 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:
timeArg - the input string
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:
timeArg - the input string
absolute - should the timestamp be parsed as an absolute time or a relative time.
parseFormat - the parse format to use when trying to parse timeStr.
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.



Timeindexing 2008