info.fingo.util
Class DateTime

java.lang.Object
  extended by info.fingo.util.DateTime

public final class DateTime
extends java.lang.Object

Date and time related helper functions.

Author:
FINGO - Robert Marek

Constructor Summary
DateTime()
           
 
Method Summary
static java.util.Vector<Pair> getDays(java.sql.Timestamp start, java.sql.Timestamp end, java.lang.String locale)
          Returns vector of dates between given start and end timestamps.
static java.util.Vector<Pair> getDays(java.sql.Timestamp start, java.sql.Timestamp end, java.lang.String locale, java.lang.String format)
          Returns vector of dates between given start and end timestamps.
static java.util.Vector<java.lang.String> getHours(int startHour, int endHour, int stepMinutes)
          Returns the hours between the given start and end hour.
static java.util.Date parseDate(java.lang.String string)
          Parse date in one of the formats: "dd.mm.yyyy", "dd.mm.yy", "yyyy.mm.dd", "dd-mm-yyyy", "yy-mm-dd", "yyyy-mm-dd", "mm/dd/yyyy", "mm/dd/yy" with one or two digits day and month and optional time in one of the formats: "hh:mm", "hh:mm:ss" with optional am/pm suffix
static java.util.GregorianCalendar parseDateToCalendar(java.lang.String string)
          Parse date in one of the formats: "dd.mm.yyyy", "dd.mm.yy", "yyyy.mm.dd", "dd-mm-yyyy", "yy-mm-dd", "yyyy-mm-dd", "mm/dd/yyyy", "mm/dd/yy" with one or two digits day and month and optional time in one of the formats: "hh:mm", "hh:mm:ss" with optional am/pm suffix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTime

public DateTime()
Method Detail

parseDate

public static java.util.Date parseDate(java.lang.String string)
Parse date in one of the formats: "dd.mm.yyyy", "dd.mm.yy", "yyyy.mm.dd", "dd-mm-yyyy", "yy-mm-dd", "yyyy-mm-dd", "mm/dd/yyyy", "mm/dd/yy" with one or two digits day and month and optional time in one of the formats: "hh:mm", "hh:mm:ss" with optional am/pm suffix

Parameters:
string - String containing date representation
Returns:
Date object or null if date cannot be parsed

parseDateToCalendar

public static java.util.GregorianCalendar parseDateToCalendar(java.lang.String string)
Parse date in one of the formats: "dd.mm.yyyy", "dd.mm.yy", "yyyy.mm.dd", "dd-mm-yyyy", "yy-mm-dd", "yyyy-mm-dd", "mm/dd/yyyy", "mm/dd/yy" with one or two digits day and month and optional time in one of the formats: "hh:mm", "hh:mm:ss" with optional am/pm suffix

Parameters:
string - String containing date representation
Returns:
GregorianCalendar object or null if date cannot be parsed

getHours

public static java.util.Vector<java.lang.String> getHours(int startHour,
                                                          int endHour,
                                                          int stepMinutes)
Returns the hours between the given start and end hour. Given minutes count defines distance between returned values.

Parameters:
startHour - the period start
endHour - the period end
stepMinutes - the distance between the returned values
Returns:
The vector of hours in HH:mm format.

getDays

public static java.util.Vector<Pair> getDays(java.sql.Timestamp start,
                                             java.sql.Timestamp end,
                                             java.lang.String locale)
Returns vector of dates between given start and end timestamps. The result are pairs where the key is the day in dd.MM.yyyy format, and the value is the same date in the format EEEE, dd. MMMM yyyy and given locale.

Parameters:
start - the period start
end - the period end
locale - the language for the locale to format the dates
Returns:
Vector of pairs

getDays

public static java.util.Vector<Pair> getDays(java.sql.Timestamp start,
                                             java.sql.Timestamp end,
                                             java.lang.String locale,
                                             java.lang.String format)
Returns vector of dates between given start and end timestamps. The result are pairs where the key is the day in dd.MM.yyyy format, and the value is the same date in the format and locale defined by the given paramters.

Parameters:
start - the period start
end - the period end
locale - the language for the locale to format the dates
format - the dates format
Returns:
Vector of pairs