org.ofbiz.base.util
Class UtilDateTime

java.lang.Object
  extended by org.ofbiz.base.util.UtilDateTime

public class UtilDateTime
extends java.lang.Object

Utility class for handling java.util.Date, the java.sql data/time classes and related


Field Summary
protected static java.util.List<java.util.TimeZone> availableTimeZoneList
           
static java.lang.String[] days
           
static java.text.DecimalFormat df
           
static java.lang.String fallBackJSPattern
          Default pattern that getJsDateTimeFormat can return in case of error or if given pattern element isn't supported by jscalendar .
static java.lang.String[] months
           
static java.lang.String[][] timevals
           
 
Constructor Summary
UtilDateTime()
           
 
Method Summary
static java.sql.Timestamp addDaysToTimestamp(java.sql.Timestamp start, java.lang.Double days)
           
static java.sql.Timestamp addDaysToTimestamp(java.sql.Timestamp start, int days)
           
static java.sql.Timestamp adjustTimestamp(java.sql.Timestamp stamp, java.lang.Integer adjType, java.lang.Integer adjQuantity)
           
static java.sql.Timestamp adjustTimestamp(java.sql.Timestamp stamp, int adjType, int adjQuantity, java.util.TimeZone timeZone, java.util.Locale locale)
          Perform date/time arithmetic on a Timestamp.
static java.util.List<java.util.TimeZone> availableTimeZones()
          Returns a List of available TimeZone objects.
static int dayNumber(java.sql.Timestamp stamp)
          returns a day number in a week for a Timestamp input
static java.lang.String formatInterval(java.util.Date from, java.util.Date thru, int count, java.util.Locale locale)
           
static java.lang.String formatInterval(java.util.Date from, java.util.Date thru, java.util.Locale locale)
           
static java.lang.String formatInterval(double interval, int count, java.util.Locale locale)
           
static java.lang.String formatInterval(double interval, java.util.Locale locale)
           
static java.lang.String formatInterval(long interval, int count, java.util.Locale locale)
           
static java.lang.String formatInterval(long interval, java.util.Locale locale)
           
static java.lang.String formatInterval(java.sql.Timestamp from, java.sql.Timestamp thru, int count, java.util.Locale locale)
           
static java.lang.String formatInterval(java.sql.Timestamp from, java.sql.Timestamp thru, java.util.Locale locale)
           
static java.lang.String getDateFormat(java.util.Locale locale)
          Returns appropriate date format string.
static java.lang.String getDateTimeFormat(java.util.Locale locale)
          Returns appropriate date + time format string.
static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp)
           
static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp, java.lang.Long daysLater)
           
static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp, java.lang.Long daysLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.util.List<java.lang.String> getDayNames(java.util.Locale locale)
          Returns a List of day name Strings - suitable for calendar headings.
static int getDayOfMonth(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static int getDayOfWeek(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static int getDayOfYear(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp)
           
static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp, int daysLater)
           
static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp, int daysLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static int getHour(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static double getInterval(java.util.Date from, java.util.Date thru)
           
static double getInterval(java.sql.Timestamp from, java.sql.Timestamp thru)
           
static int getIntervalInDays(java.sql.Timestamp from, java.sql.Timestamp thru)
           
static java.lang.String getJsDateTimeFormat(java.lang.String pattern)
          Method converts given date/time pattern in SimpleDateFormat style to form that can be used by jscalendar.
Called from FTL and form widget rendering code for setup calendar.
static int getMinute(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static int getMonth(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getMonthEnd(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.util.List<java.lang.String> getMonthNames(java.util.Locale locale)
          Returns a List of month name Strings - suitable for calendar headings.
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp)
          Return the date for the first day of the month
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, int daysLater)
           
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, int daysLater, int monthsLater)
           
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, int daysLater, int monthsLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, int daysLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getNextDayStart(java.sql.Timestamp stamp)
           
static int getSecond(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.lang.String getTimeFormat(java.util.Locale locale)
          Returns appropriate time format string.
static java.sql.Timestamp getTimestamp(long time)
          Convert a millisecond value to a Timestamp.
static java.sql.Timestamp getTimestamp(java.lang.String milliSecs)
          Convert a millisecond value to a Timestamp.
static int getWeek(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getWeekEnd(java.sql.Timestamp stamp)
           
static java.sql.Timestamp getWeekEnd(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp)
          Return the date for the first day of the week
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, int daysLater)
           
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, int daysLater, int weeksLater)
           
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, int daysLater, int weeksLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, int daysLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static int getYear(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearEnd(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp)
          Return the date for the first day of the year
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater, int yearsLater)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater, int monthsLater, int yearsLater)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater, int monthsLater, int yearsLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater, int yearsLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, int daysLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, java.lang.Number daysLater, java.lang.Number monthsLater, java.lang.Number yearsLater)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, java.lang.Number daysLater, java.lang.Number monthsLater, java.lang.Number yearsLater, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
static java.sql.Timestamp monthBegin()
          Makes a Timestamp for the beginning of the month
static java.lang.String nowAsString()
          Returns currentTimeMillis as String
static java.util.Date nowDate()
          Return a Date for right now
static java.lang.String nowDateString()
          Return a string formatted as yyyyMMddHHmmss
static java.lang.String nowDateString(java.lang.String format)
          Return a string formatted as format
static java.sql.Timestamp nowTimestamp()
          Return a Timestamp for right now
static java.sql.Timestamp stringToTimeStamp(java.lang.String dateTimeString, java.lang.String dateTimeFormat, java.util.TimeZone tz, java.util.Locale locale)
          Localized String to Timestamp conversion.
static java.sql.Timestamp stringToTimeStamp(java.lang.String dateTimeString, java.util.TimeZone tz, java.util.Locale locale)
          Localized String to Timestamp conversion.
static java.lang.String timeStampToString(java.sql.Timestamp stamp, java.lang.String dateTimeFormat, java.util.TimeZone tz, java.util.Locale locale)
          Localized Timestamp to String conversion.
static java.lang.String timeStampToString(java.sql.Timestamp stamp, java.util.TimeZone tz, java.util.Locale locale)
          Localized Timestamp to String conversion.
static java.util.Calendar toCalendar(java.util.Date date, java.util.TimeZone timeZone, java.util.Locale locale)
          Returns a Calendar object initialized to the specified date/time, time zone, and locale.
static java.util.Calendar toCalendar(java.sql.Timestamp stamp)
           
static java.util.Date toDate(int month, int day, int year, int hour, int minute, int second)
          Makes a Date from separate ints for month, day, year, hour, minute, and second.
static java.util.Date toDate(java.lang.String dateTime)
          Converts a date and time String into a Date
static java.util.Date toDate(java.lang.String date, java.lang.String time)
          Converts a date String and a time String into a Date
static java.util.Date toDate(java.lang.String monthStr, java.lang.String dayStr, java.lang.String yearStr, java.lang.String hourStr, java.lang.String minuteStr, java.lang.String secondStr)
          Makes a Date from separate Strings for month, day, year, hour, minute, and second.
static java.text.DateFormat toDateFormat(java.lang.String dateFormat, java.util.TimeZone tz, java.util.Locale locale)
          Returns an initialized DateFormat object.
static java.lang.String toDateString(java.util.Date date)
          Makes a date String in the format MM/DD/YYYY from a Date
static java.lang.String toDateString(java.util.Date date, java.lang.String format)
          Makes a date String in the given from a Date
static java.text.DateFormat toDateTimeFormat(java.lang.String dateTimeFormat, java.util.TimeZone tz, java.util.Locale locale)
          Returns an initialized DateFormat object.
static java.lang.String toDateTimeString(java.util.Date date)
          Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date.
static java.lang.String toGmtTimestampString(java.sql.Timestamp timestamp)
           
static java.sql.Date toSqlDate(int month, int day, int year)
          Makes a java.sql.Date from separate ints for month, day, year
static java.sql.Date toSqlDate(java.lang.String date)
          Converts a date String into a java.sql.Date
static java.sql.Date toSqlDate(java.lang.String monthStr, java.lang.String dayStr, java.lang.String yearStr)
          Makes a java.sql.Date from separate Strings for month, day, year
static java.sql.Time toSqlTime(int hour, int minute, int second)
          Makes a java.sql.Time from separate ints for hour, minute, and second.
static java.sql.Time toSqlTime(java.lang.String time)
          Converts a time String into a java.sql.Time
static java.sql.Time toSqlTime(java.lang.String hourStr, java.lang.String minuteStr, java.lang.String secondStr)
          Makes a java.sql.Time from separate Strings for hour, minute, and second.
static java.text.DateFormat toTimeFormat(java.lang.String timeFormat, java.util.TimeZone tz, java.util.Locale locale)
          Returns an initialized DateFormat object.
static java.sql.Timestamp toTimestamp(java.util.Date date)
           
static java.sql.Timestamp toTimestamp(int month, int day, int year, int hour, int minute, int second)
          Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.
static java.sql.Timestamp toTimestamp(java.lang.String dateTime)
          Converts a date and time String into a Timestamp
static java.sql.Timestamp toTimestamp(java.lang.String date, java.lang.String time)
          Converts a date String and a time String into a Timestamp
static java.sql.Timestamp toTimestamp(java.lang.String monthStr, java.lang.String dayStr, java.lang.String yearStr, java.lang.String hourStr, java.lang.String minuteStr, java.lang.String secondStr)
          Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.
static java.lang.String toTimeString(java.util.Date date)
          Makes a time String in the format HH:MM:SS from a Date.
static java.lang.String toTimeString(int hour, int minute, int second)
          Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second.
static java.util.TimeZone toTimeZone(int gmtOffset)
          Returns a TimeZone object based upon an hour offset from GMT.
static java.util.TimeZone toTimeZone(java.lang.String tzId)
          Returns a TimeZone object based upon a time zone ID.
static int weekNumber(java.sql.Timestamp input)
          returns a week number in a year for a Timestamp input
static int weekNumber(java.sql.Timestamp input, int startOfWeek)
           
static int weekNumber(java.sql.Timestamp stamp, java.util.TimeZone timeZone, java.util.Locale locale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

months

public static final java.lang.String[] months

days

public static final java.lang.String[] days

timevals

public static final java.lang.String[][] timevals

df

public static final java.text.DecimalFormat df

availableTimeZoneList

protected static java.util.List<java.util.TimeZone> availableTimeZoneList

fallBackJSPattern

public static final java.lang.String fallBackJSPattern
Default pattern that getJsDateTimeFormat can return in case of error or if given pattern element isn't supported by jscalendar .

See Also:
Constant Field Values
Constructor Detail

UtilDateTime

public UtilDateTime()
Method Detail

getInterval

public static double getInterval(java.util.Date from,
                                 java.util.Date thru)

getIntervalInDays

public static int getIntervalInDays(java.sql.Timestamp from,
                                    java.sql.Timestamp thru)

addDaysToTimestamp

public static java.sql.Timestamp addDaysToTimestamp(java.sql.Timestamp start,
                                                    int days)

addDaysToTimestamp

public static java.sql.Timestamp addDaysToTimestamp(java.sql.Timestamp start,
                                                    java.lang.Double days)

getInterval

public static double getInterval(java.sql.Timestamp from,
                                 java.sql.Timestamp thru)

formatInterval

public static java.lang.String formatInterval(java.util.Date from,
                                              java.util.Date thru,
                                              int count,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(java.util.Date from,
                                              java.util.Date thru,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(java.sql.Timestamp from,
                                              java.sql.Timestamp thru,
                                              int count,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(java.sql.Timestamp from,
                                              java.sql.Timestamp thru,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(long interval,
                                              int count,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(long interval,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(double interval,
                                              java.util.Locale locale)

formatInterval

public static java.lang.String formatInterval(double interval,
                                              int count,
                                              java.util.Locale locale)

nowTimestamp

public static java.sql.Timestamp nowTimestamp()
Return a Timestamp for right now

Returns:
Timestamp for right now

getTimestamp

public static java.sql.Timestamp getTimestamp(long time)
Convert a millisecond value to a Timestamp.

Parameters:
time - millsecond value
Returns:
Timestamp

getTimestamp

public static java.sql.Timestamp getTimestamp(java.lang.String milliSecs)
                                       throws java.lang.NumberFormatException
Convert a millisecond value to a Timestamp.

Parameters:
milliSecs - millsecond value
Returns:
Timestamp
Throws:
java.lang.NumberFormatException

nowAsString

public static java.lang.String nowAsString()
Returns currentTimeMillis as String

Returns:
String(currentTimeMillis)

nowDateString

public static java.lang.String nowDateString()
Return a string formatted as yyyyMMddHHmmss

Returns:
String formatted for right now

nowDateString

public static java.lang.String nowDateString(java.lang.String format)
Return a string formatted as format

Returns:
String formatted for right now

nowDate

public static java.util.Date nowDate()
Return a Date for right now

Returns:
Date for right now

getDayStart

public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp)

getDayStart

public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp,
                                             int daysLater)

getNextDayStart

public static java.sql.Timestamp getNextDayStart(java.sql.Timestamp stamp)

getDayEnd

public static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp)

getDayEnd

public static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp,
                                           java.lang.Long daysLater)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp)
Return the date for the first day of the year

Parameters:
stamp -
Returns:
java.sql.Timestamp

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int yearsLater)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int monthsLater,
                                              int yearsLater)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              java.lang.Number daysLater,
                                              java.lang.Number monthsLater,
                                              java.lang.Number yearsLater)

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp)
Return the date for the first day of the month

Parameters:
stamp -
Returns:
java.sql.Timestamp

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp,
                                               int daysLater)

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp,
                                               int daysLater,
                                               int monthsLater)

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp)
Return the date for the first day of the week

Parameters:
stamp -
Returns:
java.sql.Timestamp

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp,
                                              int daysLater)

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int weeksLater)

getWeekEnd

public static java.sql.Timestamp getWeekEnd(java.sql.Timestamp stamp)

toCalendar

public static java.util.Calendar toCalendar(java.sql.Timestamp stamp)

toSqlDate

public static java.sql.Date toSqlDate(java.lang.String date)
Converts a date String into a java.sql.Date

Parameters:
date - The date String: MM/DD/YYYY
Returns:
A java.sql.Date made from the date String

toSqlDate

public static java.sql.Date toSqlDate(java.lang.String monthStr,
                                      java.lang.String dayStr,
                                      java.lang.String yearStr)
Makes a java.sql.Date from separate Strings for month, day, year

Parameters:
monthStr - The month String
dayStr - The day String
yearStr - The year String
Returns:
A java.sql.Date made from separate Strings for month, day, year

toSqlDate

public static java.sql.Date toSqlDate(int month,
                                      int day,
                                      int year)
Makes a java.sql.Date from separate ints for month, day, year

Parameters:
month - The month int
day - The day int
year - The year int
Returns:
A java.sql.Date made from separate ints for month, day, year

toSqlTime

public static java.sql.Time toSqlTime(java.lang.String time)
Converts a time String into a java.sql.Time

Parameters:
time - The time String: either HH:MM or HH:MM:SS
Returns:
A java.sql.Time made from the time String

toSqlTime

public static java.sql.Time toSqlTime(java.lang.String hourStr,
                                      java.lang.String minuteStr,
                                      java.lang.String secondStr)
Makes a java.sql.Time from separate Strings for hour, minute, and second.

Parameters:
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
Returns:
A java.sql.Time made from separate Strings for hour, minute, and second.

toSqlTime

public static java.sql.Time toSqlTime(int hour,
                                      int minute,
                                      int second)
Makes a java.sql.Time from separate ints for hour, minute, and second.

Parameters:
hour - The hour int
minute - The minute int
second - The second int
Returns:
A java.sql.Time made from separate ints for hour, minute, and second.

toTimestamp

public static java.sql.Timestamp toTimestamp(java.lang.String dateTime)
Converts a date and time String into a Timestamp

Parameters:
dateTime - A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional
Returns:
The corresponding Timestamp

toTimestamp

public static java.sql.Timestamp toTimestamp(java.lang.String date,
                                             java.lang.String time)
Converts a date String and a time String into a Timestamp

Parameters:
date - The date String: MM/DD/YYYY
time - The time String: either HH:MM or HH:MM:SS
Returns:
A Timestamp made from the date and time Strings

toTimestamp

public static java.sql.Timestamp toTimestamp(java.lang.String monthStr,
                                             java.lang.String dayStr,
                                             java.lang.String yearStr,
                                             java.lang.String hourStr,
                                             java.lang.String minuteStr,
                                             java.lang.String secondStr)
Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.

Parameters:
monthStr - The month String
dayStr - The day String
yearStr - The year String
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
Returns:
A Timestamp made from separate Strings for month, day, year, hour, minute, and second.

toTimestamp

public static java.sql.Timestamp toTimestamp(int month,
                                             int day,
                                             int year,
                                             int hour,
                                             int minute,
                                             int second)
Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.

Parameters:
month - The month int
day - The day int
year - The year int
hour - The hour int
minute - The minute int
second - The second int
Returns:
A Timestamp made from separate ints for month, day, year, hour, minute, and second.

toTimestamp

public static java.sql.Timestamp toTimestamp(java.util.Date date)

toDate

public static java.util.Date toDate(java.lang.String dateTime)
Converts a date and time String into a Date

Parameters:
dateTime - A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional
Returns:
The corresponding Date

toDate

public static java.util.Date toDate(java.lang.String date,
                                    java.lang.String time)
Converts a date String and a time String into a Date

Parameters:
date - The date String: MM/DD/YYYY
time - The time String: either HH:MM or HH:MM:SS
Returns:
A Date made from the date and time Strings

toDate

public static java.util.Date toDate(java.lang.String monthStr,
                                    java.lang.String dayStr,
                                    java.lang.String yearStr,
                                    java.lang.String hourStr,
                                    java.lang.String minuteStr,
                                    java.lang.String secondStr)
Makes a Date from separate Strings for month, day, year, hour, minute, and second.

Parameters:
monthStr - The month String
dayStr - The day String
yearStr - The year String
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
Returns:
A Date made from separate Strings for month, day, year, hour, minute, and second.

toDate

public static java.util.Date toDate(int month,
                                    int day,
                                    int year,
                                    int hour,
                                    int minute,
                                    int second)
Makes a Date from separate ints for month, day, year, hour, minute, and second.

Parameters:
month - The month int
day - The day int
year - The year int
hour - The hour int
minute - The minute int
second - The second int
Returns:
A Date made from separate ints for month, day, year, hour, minute, and second.

toDateString

public static java.lang.String toDateString(java.util.Date date,
                                            java.lang.String format)
Makes a date String in the given from a Date

Parameters:
date - The Date
Returns:
A date String in the given format

toDateString

public static java.lang.String toDateString(java.util.Date date)
Makes a date String in the format MM/DD/YYYY from a Date

Parameters:
date - The Date
Returns:
A date String in the format MM/DD/YYYY

toTimeString

public static java.lang.String toTimeString(java.util.Date date)
Makes a time String in the format HH:MM:SS from a Date. If the seconds are 0, then the output is in HH:MM.

Parameters:
date - The Date
Returns:
A time String in the format HH:MM:SS or HH:MM

toTimeString

public static java.lang.String toTimeString(int hour,
                                            int minute,
                                            int second)
Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second. If the seconds are 0, then the output is in HH:MM.

Parameters:
hour - The hour int
minute - The minute int
second - The second int
Returns:
A time String in the format HH:MM:SS or HH:MM

toDateTimeString

public static java.lang.String toDateTimeString(java.util.Date date)
Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date. If the seconds are 0 they are left off.

Parameters:
date - The Date
Returns:
A combined data and time string in the format "MM/DD/YYYY HH:MM:SS" where the seconds are left off if they are 0.

toGmtTimestampString

public static java.lang.String toGmtTimestampString(java.sql.Timestamp timestamp)

monthBegin

public static java.sql.Timestamp monthBegin()
Makes a Timestamp for the beginning of the month

Returns:
A Timestamp of the beginning of the month

weekNumber

public static int weekNumber(java.sql.Timestamp input)
returns a week number in a year for a Timestamp input

Parameters:
input - Timestamp date
Returns:
A int containing the week number

dayNumber

public static int dayNumber(java.sql.Timestamp stamp)
returns a day number in a week for a Timestamp input

Parameters:
stamp - Timestamp date
Returns:
A int containing the day number (sunday = 1, saturday = 7)

weekNumber

public static int weekNumber(java.sql.Timestamp input,
                             int startOfWeek)

toCalendar

public static java.util.Calendar toCalendar(java.util.Date date,
                                            java.util.TimeZone timeZone,
                                            java.util.Locale locale)
Returns a Calendar object initialized to the specified date/time, time zone, and locale.

Parameters:
date - date/time to use
timeZone -
locale -
Returns:
Calendar object
See Also:
Calendar

adjustTimestamp

public static java.sql.Timestamp adjustTimestamp(java.sql.Timestamp stamp,
                                                 int adjType,
                                                 int adjQuantity,
                                                 java.util.TimeZone timeZone,
                                                 java.util.Locale locale)
Perform date/time arithmetic on a Timestamp. This is the only accurate way to perform date/time arithmetic across locales and time zones.

Parameters:
stamp - date/time to perform arithmetic on
adjType - the adjustment type to perform. Use one of the java.util.Calendar fields.
adjQuantity - the adjustment quantity.
timeZone -
locale -
Returns:
adjusted Timestamp
See Also:
Calendar

adjustTimestamp

public static java.sql.Timestamp adjustTimestamp(java.sql.Timestamp stamp,
                                                 java.lang.Integer adjType,
                                                 java.lang.Integer adjQuantity)

getDayStart

public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp,
                                             java.util.TimeZone timeZone,
                                             java.util.Locale locale)

getDayStart

public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp,
                                             int daysLater,
                                             java.util.TimeZone timeZone,
                                             java.util.Locale locale)

getDayEnd

public static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp,
                                           java.util.TimeZone timeZone,
                                           java.util.Locale locale)

getDayEnd

public static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp,
                                           java.lang.Long daysLater,
                                           java.util.TimeZone timeZone,
                                           java.util.Locale locale)

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getWeekStart

public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int weeksLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getWeekEnd

public static java.sql.Timestamp getWeekEnd(java.sql.Timestamp stamp,
                                            java.util.TimeZone timeZone,
                                            java.util.Locale locale)

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp,
                                               java.util.TimeZone timeZone,
                                               java.util.Locale locale)

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp,
                                               int daysLater,
                                               java.util.TimeZone timeZone,
                                               java.util.Locale locale)

getMonthStart

public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp,
                                               int daysLater,
                                               int monthsLater,
                                               java.util.TimeZone timeZone,
                                               java.util.Locale locale)

getMonthEnd

public static java.sql.Timestamp getMonthEnd(java.sql.Timestamp stamp,
                                             java.util.TimeZone timeZone,
                                             java.util.Locale locale)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int yearsLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              java.lang.Number daysLater,
                                              java.lang.Number monthsLater,
                                              java.lang.Number yearsLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getYearStart

public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp,
                                              int daysLater,
                                              int monthsLater,
                                              int yearsLater,
                                              java.util.TimeZone timeZone,
                                              java.util.Locale locale)

getYearEnd

public static java.sql.Timestamp getYearEnd(java.sql.Timestamp stamp,
                                            java.util.TimeZone timeZone,
                                            java.util.Locale locale)

weekNumber

public static int weekNumber(java.sql.Timestamp stamp,
                             java.util.TimeZone timeZone,
                             java.util.Locale locale)

getDayNames

public static java.util.List<java.lang.String> getDayNames(java.util.Locale locale)
Returns a List of day name Strings - suitable for calendar headings.

Parameters:
locale -
Returns:
List of day name Strings

getMonthNames

public static java.util.List<java.lang.String> getMonthNames(java.util.Locale locale)
Returns a List of month name Strings - suitable for calendar headings.

Parameters:
locale -
Returns:
List of month name Strings

toDateFormat

public static java.text.DateFormat toDateFormat(java.lang.String dateFormat,
                                                java.util.TimeZone tz,
                                                java.util.Locale locale)
Returns an initialized DateFormat object.

Parameters:
dateFormat - optional format string
tz -
locale - can be null if dateFormat is not null
Returns:
DateFormat object

toDateTimeFormat

public static java.text.DateFormat toDateTimeFormat(java.lang.String dateTimeFormat,
                                                    java.util.TimeZone tz,
                                                    java.util.Locale locale)
Returns an initialized DateFormat object.

Parameters:
dateTimeFormat - optional format string
tz -
locale - can be null if dateTimeFormat is not null
Returns:
DateFormat object

toTimeFormat

public static java.text.DateFormat toTimeFormat(java.lang.String timeFormat,
                                                java.util.TimeZone tz,
                                                java.util.Locale locale)
Returns an initialized DateFormat object.

Parameters:
timeFormat - optional format string
tz -
locale - can be null if timeFormat is not null
Returns:
DateFormat object

stringToTimeStamp

public static java.sql.Timestamp stringToTimeStamp(java.lang.String dateTimeString,
                                                   java.util.TimeZone tz,
                                                   java.util.Locale locale)
                                            throws java.text.ParseException
Localized String to Timestamp conversion. To be used in tandem with timeStampToString().

Throws:
java.text.ParseException

stringToTimeStamp

public static java.sql.Timestamp stringToTimeStamp(java.lang.String dateTimeString,
                                                   java.lang.String dateTimeFormat,
                                                   java.util.TimeZone tz,
                                                   java.util.Locale locale)
                                            throws java.text.ParseException
Localized String to Timestamp conversion. To be used in tandem with timeStampToString().

Throws:
java.text.ParseException

timeStampToString

public static java.lang.String timeStampToString(java.sql.Timestamp stamp,
                                                 java.util.TimeZone tz,
                                                 java.util.Locale locale)
Localized Timestamp to String conversion. To be used in tandem with stringToTimeStamp().


timeStampToString

public static java.lang.String timeStampToString(java.sql.Timestamp stamp,
                                                 java.lang.String dateTimeFormat,
                                                 java.util.TimeZone tz,
                                                 java.util.Locale locale)
Localized Timestamp to String conversion. To be used in tandem with stringToTimeStamp().


availableTimeZones

public static java.util.List<java.util.TimeZone> availableTimeZones()
Returns a List of available TimeZone objects.

See Also:
TimeZone

toTimeZone

public static java.util.TimeZone toTimeZone(java.lang.String tzId)
Returns a TimeZone object based upon a time zone ID. Method defaults to server's time zone if tzID is null or empty.

See Also:
TimeZone

toTimeZone

public static java.util.TimeZone toTimeZone(int gmtOffset)
Returns a TimeZone object based upon an hour offset from GMT.

See Also:
TimeZone

getSecond

public static int getSecond(java.sql.Timestamp stamp,
                            java.util.TimeZone timeZone,
                            java.util.Locale locale)

getMinute

public static int getMinute(java.sql.Timestamp stamp,
                            java.util.TimeZone timeZone,
                            java.util.Locale locale)

getHour

public static int getHour(java.sql.Timestamp stamp,
                          java.util.TimeZone timeZone,
                          java.util.Locale locale)

getDayOfWeek

public static int getDayOfWeek(java.sql.Timestamp stamp,
                               java.util.TimeZone timeZone,
                               java.util.Locale locale)

getDayOfMonth

public static int getDayOfMonth(java.sql.Timestamp stamp,
                                java.util.TimeZone timeZone,
                                java.util.Locale locale)

getDayOfYear

public static int getDayOfYear(java.sql.Timestamp stamp,
                               java.util.TimeZone timeZone,
                               java.util.Locale locale)

getWeek

public static int getWeek(java.sql.Timestamp stamp,
                          java.util.TimeZone timeZone,
                          java.util.Locale locale)

getMonth

public static int getMonth(java.sql.Timestamp stamp,
                           java.util.TimeZone timeZone,
                           java.util.Locale locale)

getYear

public static int getYear(java.sql.Timestamp stamp,
                          java.util.TimeZone timeZone,
                          java.util.Locale locale)

getTimeFormat

public static java.lang.String getTimeFormat(java.util.Locale locale)
Returns appropriate time format string.

Parameters:
locale - User's locale, may be null
Returns:
Time format string

getDateTimeFormat

public static java.lang.String getDateTimeFormat(java.util.Locale locale)
Returns appropriate date + time format string.

Parameters:
locale - User's locale, may be null.
Returns:
Date/time format string

getDateFormat

public static java.lang.String getDateFormat(java.util.Locale locale)
Returns appropriate date format string.

Parameters:
locale - User's locale, may be null
Returns:
Date format string

getJsDateTimeFormat

public static java.lang.String getJsDateTimeFormat(java.lang.String pattern)
Method converts given date/time pattern in SimpleDateFormat style to form that can be used by jscalendar.
Called from FTL and form widget rendering code for setup calendar.

Parameters:
pattern - Pattern to convert. Results of getDate[Time]Format(locale) as a rule.
Returns:
Date/time format pattern that conforms to jscalendar requirements.