uk.ac.ic.doc.automed.util
Class DateUtil

java.lang.Object
  extended by uk.ac.ic.doc.automed.util.DateUtil

public class DateUtil
extends java.lang.Object


Field Summary
private static java.util.Calendar _cal
           
private static java.text.DateFormat _dateFormat
           
private static java.text.DateFormat _iqlDateFormat
           
 
Constructor Summary
private DateUtil()
           
 
Method Summary
static java.util.Date formatIQLDate(java.lang.String ds)
          Convert an IQL date time string into a Date object
static java.lang.String getBriefDateString()
          Return a brief date string of current date
Example: 20/7/2006 1:1:1---> 20060720
static java.lang.String getClockRepresentation(java.util.Date dateObj)
          Return a standard clock representation of a Date object
static java.lang.String getClockRepresentation(long numMilliSecs)
          Return a standard clock representation from the number of millisecs
static java.lang.String getClockRepresentation(long[] timeElements)
          Return a standard clock representation of a time value.
static java.util.Date getCurrentDate()
          Return the current date/time in a standard format
static java.lang.String getDate()
          Return the current date/time in a standard format
static java.util.Date getDate(long millisecs)
          Return a date from number of its milli-seconds
static long getDateAsMillisecs()
          Return the current date as the number of milli-seconds
static long getDateAsMillisecs(java.lang.String dstr)
           
static java.util.Date getDateInstance(java.lang.String dstr)
           
static java.lang.String getDateString()
          Return a date string of current date
Example: 20/7/2006 1:1:1---> 20060720_010101
static java.util.Date getIQLDateInstance(java.lang.String dstr)
           
static long getMilliseconds(java.util.Date dateObj)
          Convert a Date object into the number of milliseconds from start of the clock
static boolean isGreaterThanOrEqualTo(java.util.Date date1, java.util.Date date2)
           
static void main(java.lang.String[] args)
           
static long[] subtractDate(java.util.Date date1, java.util.Date date2)
          Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds
static long[] subtractDate(java.util.Date date1, int numDays)
          Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds
static long[] subtractDate(long date1AsMillisecs, long date2AsMillisecs)
          Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_cal

private static java.util.Calendar _cal

_dateFormat

private static java.text.DateFormat _dateFormat

_iqlDateFormat

private static java.text.DateFormat _iqlDateFormat
Constructor Detail

DateUtil

private DateUtil()
Method Detail

formatIQLDate

public static java.util.Date formatIQLDate(java.lang.String ds)
Convert an IQL date time string into a Date object


subtractDate

public static long[] subtractDate(java.util.Date date1,
                                  java.util.Date date2)
Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds

Parameters:
date1 - Date object to be subtracted
date2 - Date object to be subtracted from (i.e. date2 - date1)
Returns:
long[] a long-type array of hours, minutes and seconds

isGreaterThanOrEqualTo

public static boolean isGreaterThanOrEqualTo(java.util.Date date1,
                                             java.util.Date date2)

subtractDate

public static long[] subtractDate(java.util.Date date1,
                                  int numDays)
Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds

Parameters:
date1 - Date object to be subtracted
numDays - the number of days to be subtracted from date1
Returns:
long[] a long-type array of hours, minutes and seconds

subtractDate

public static long[] subtractDate(long date1AsMillisecs,
                                  long date2AsMillisecs)
Subtract Date1 from Date2 to return the result as an array of numbers of hours, minutes, and seconds

Parameters:
date1 - first date as the number of millseconds
date2 - second date as the number of millseconds
Returns:
long[] a long-type array of hours, minutes and seconds

getDate

public static java.lang.String getDate()
Return the current date/time in a standard format

Parameters:
String - date/time string

getCurrentDate

public static java.util.Date getCurrentDate()
Return the current date/time in a standard format

Parameters:
String - date/time string

getDateAsMillisecs

public static long getDateAsMillisecs()
Return the current date as the number of milli-seconds


getDateAsMillisecs

public static long getDateAsMillisecs(java.lang.String dstr)

getDate

public static java.util.Date getDate(long millisecs)
Return a date from number of its milli-seconds


getDateString

public static java.lang.String getDateString()
Return a date string of current date
Example: 20/7/2006 1:1:1---> 20060720_010101


getBriefDateString

public static java.lang.String getBriefDateString()
Return a brief date string of current date
Example: 20/7/2006 1:1:1---> 20060720


getMilliseconds

public static long getMilliseconds(java.util.Date dateObj)
Convert a Date object into the number of milliseconds from start of the clock


getClockRepresentation

public static java.lang.String getClockRepresentation(long numMilliSecs)
Return a standard clock representation from the number of millisecs


getClockRepresentation

public static java.lang.String getClockRepresentation(java.util.Date dateObj)
Return a standard clock representation of a Date object


getClockRepresentation

public static java.lang.String getClockRepresentation(long[] timeElements)
Return a standard clock representation of a time value. For example, this
method represents a time value of 2 hours, 30 minutes and 33 seconds as
02:30:33. It is a useful representation for age-time.

Parameters:
{@link - long}[] an array of time elements, typically the number of hours,
minutes and seconds
Returns:
String the clock representation of time value

main

public static void main(java.lang.String[] args)

getDateInstance

public static java.util.Date getDateInstance(java.lang.String dstr)

getIQLDateInstance

public static java.util.Date getIQLDateInstance(java.lang.String dstr)