org.qriterium.dogma
Class DogmaTime

java.lang.Object
  extended by org.qriterium.dogma.DogmaTime

public class DogmaTime
extends java.lang.Object

DogmaTime is a class for timestamps and time management used in Dogma.

Version:
%I%, %G%

Constructor Summary
DogmaTime()
          Creates a new DogmaTime instance.
DogmaTime(java.util.Date date)
          Creates a new DogmaTime from given java.util.Date
DogmaTime(int year, int month, int date, int hour, int min, int sec)
          Creates a new DogmaTime instance with given values for time.
DogmaTime(java.lang.String time)
          Creates a new DogmaTime-instance based on the given time.
 
Method Summary
 int compareTo(DogmaTime t)
          Compares the time in current object with the given one.
static java.lang.String getCurrentTime()
          Returns the current time as a String
 java.util.Date getDate()
           
static java.lang.String getFormattedString(java.lang.String time)
           
 boolean isBetween(DogmaTime s, DogmaTime e)
          Returns true if the current DogmaTime is between the given DogmaTimes.
 void now()
          Resets the time to current time.
static java.lang.String parseDate(java.lang.String date)
          Makes a conversion from String towards DogmaTime-format
 java.lang.String toString()
          Returns the time in String-format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DogmaTime

public DogmaTime()
Creates a new DogmaTime instance.


DogmaTime

public DogmaTime(int year,
                 int month,
                 int date,
                 int hour,
                 int min,
                 int sec)
Creates a new DogmaTime instance with given values for time. Months and days start from one.

Parameters:
year - Current year, for example 2007.
month - Current month, for example 1 for january.
date - Current date.
hour - Current hour.
min - Current Minute.
sec - Current Second.

DogmaTime

public DogmaTime(java.lang.String time)
Creates a new DogmaTime-instance based on the given time.

Parameters:
time - Input string should be in format YYYYMMDDhhmmss

DogmaTime

public DogmaTime(java.util.Date date)
Creates a new DogmaTime from given java.util.Date

Parameters:
date -
Method Detail

compareTo

public int compareTo(DogmaTime t)
Compares the time in current object with the given one.

Parameters:
t - the time with which the current object should be compared with is given in DogmaTime-format.
Returns:
Returns -1 if the given DogmaTime is before the current object. Returns 0 if the times are equal. Returns 1 if the given DogmaTime is after the current object.

isBetween

public boolean isBetween(DogmaTime s,
                         DogmaTime e)
Returns true if the current DogmaTime is between the given DogmaTimes.

Parameters:
s - Starting DogmaTime
e - Ending DogmaTime
Returns:
Returns true if the current DogmaTime is between the given times. Returns false otherwise.

now

public void now()
Resets the time to current time.


toString

public java.lang.String toString()
Returns the time in String-format. YYYYMMDDhhmmss

Overrides:
toString in class java.lang.Object

getCurrentTime

public static java.lang.String getCurrentTime()
Returns the current time as a String

Returns:
Time is returned in format YYYYMMDDhhmmss

getFormattedString

public static java.lang.String getFormattedString(java.lang.String time)
Parameters:
time -
Returns:
Time is returned in format YYYY MM-DD hh-mm-ss

parseDate

public static java.lang.String parseDate(java.lang.String date)
Makes a conversion from String towards DogmaTime-format

Parameters:
date - is assumed to be in format YYYY MM-DD hh-mm-ss, or format that is substring of previous starting from index 0. For example 1982 05-12 is valid, it will be converted to String 19820512000000. 1982 5-12 is not valid form.
Returns:
String-object, or null if parsing didn't succeed.

getDate

public java.util.Date getDate()