com.wewebu.ow.server.util
Class OwDateTimeUtil

java.lang.Object
  extended by com.wewebu.ow.server.util.OwDateTimeUtil

public class OwDateTimeUtil
extends Object

Utility class for manipulating date and time.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
static int NUMBER_OF_MONTHS
          number of months in year
static int NUMBER_OF_WEEKDAYS
          number of days in a week
 
Constructor Summary
OwDateTimeUtil()
           
 
Method Summary
static Date convert(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p)
          Converts a given Date represented time stamp from a time zone to another.
static Calendar convertToCalendar(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p)
          Convert a date into Calendar representation with specific time zone.
static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p)
          Convert between defined time zone's and also transform the result into an XMLGregorianCalendar.
static SimpleDateFormat createDateFromat(Locale locale_p, String sDateFormat_p)
          Create a SimpleDateFormat object.
static String[] getMonthNames(Locale locale_p)
          Get the month names.
static String[] getShortMonthNames(Locale locale_p)
          Get the short names for months of the year.
static String[] getShortWeekDays(Locale locale_p)
          Get the shorten names for week days.
static String[] getWeekDays(Locale locale_p)
          Get the weekdays, as they are configured in the locale files.
static Date offsetDay(Date date_p, int iDays_p)
          Sets a day offset in absolute time (no DST adjustment).
static Date offsetDay(Date date_p, int iDays_p, boolean dst_p)
          Sets a day offset in absolute time with the possibility of Daylight Savings Time adjustment.
static String removeDateFormatTokens(String sDateFormat_p)
          Remove all date formating from the given date-format string
static String removeTimeFormatTokens(String sDateFormat_p)
          remove all time formating from the given date format string e.g.: "dd.MM.yyyy (HH:mm)" becomes "dd.MM.yyyy"
static Date setBeginOfDayTime(Date date_p)
          set the time of the given date to the begin of a day i.e.
static Date setBeginOfNextDayTime(Date date_p)
          set the time of the given date to the begin of the NEXT day i.e.
static Date setEndOfDayTime(Date date_p)
          set the time of the given date to the end of a day i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_OF_WEEKDAYS

public static final int NUMBER_OF_WEEKDAYS
number of days in a week

See Also:
Constant Field Values

NUMBER_OF_MONTHS

public static final int NUMBER_OF_MONTHS
number of months in year

See Also:
Constant Field Values
Constructor Detail

OwDateTimeUtil

public OwDateTimeUtil()
Method Detail

setBeginOfDayTime

public static Date setBeginOfDayTime(Date date_p)
set the time of the given date to the begin of a day i.e. 00:00:00

Parameters:
date_p - Date
Returns:
Date

setBeginOfNextDayTime

public static Date setBeginOfNextDayTime(Date date_p)
set the time of the given date to the begin of the NEXT day i.e. 00:00:00

Parameters:
date_p - Date
Returns:
Date

offsetDay

public static Date offsetDay(Date date_p,
                             int iDays_p)
Sets a day offset in absolute time (no DST adjustment).

Parameters:
iDays_p - int
Returns:
Date

offsetDay

public static Date offsetDay(Date date_p,
                             int iDays_p,
                             boolean dst_p)
Sets a day offset in absolute time with the possibility of Daylight Savings Time adjustment.

Parameters:
date_p - base Date
iDays_p - number of days to add to the base date (can be a negative number)
dst_p - if true a DST adjustment will be performed
if false absolute time will be used
Returns:
a Date before of after the given date with the specified amount of days
Since:
3.1.0.0

setEndOfDayTime

public static Date setEndOfDayTime(Date date_p)
set the time of the given date to the end of a day i.e. 23:59:59

Parameters:
date_p - Date
Returns:
Date

removeTimeFormatTokens

public static String removeTimeFormatTokens(String sDateFormat_p)
remove all time formating from the given date format string e.g.: "dd.MM.yyyy (HH:mm)" becomes "dd.MM.yyyy"

Returns:
date format String e.g.: "dd.MM.yyyy"

removeDateFormatTokens

public static String removeDateFormatTokens(String sDateFormat_p)
Remove all date formating from the given date-format string

Parameters:
sDateFormat_p - the date format to be cleared of date tokens
Returns:
date format String e.g.: "HH:mm:ss"

getMonthNames

public static String[] getMonthNames(Locale locale_p)
Get the month names. Returns an array of 13 elements, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4146173 for explanations

Parameters:
locale_p - - the Locale object
Returns:
the month names.
Since:
3.0.0.0

getShortMonthNames

public static String[] getShortMonthNames(Locale locale_p)
Get the short names for months of the year.

Parameters:
locale_p -
Returns:
an array of String objects, representing the short names for months
Since:
3.0.0.0

getWeekDays

public static String[] getWeekDays(Locale locale_p)
Get the weekdays, as they are configured in the locale files. The returned array has 8 elements, see explanations at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4146173

Parameters:
locale_p - - the Locale object
Returns:
an array of String object, representing the names of the week days, for the given Locale object.

getShortWeekDays

public static String[] getShortWeekDays(Locale locale_p)
Get the shorten names for week days.

Parameters:
locale_p - - the Locale object.
Returns:
an array of String object, representing the names of the week days, for the given Locale object.

createDateFromat

public static SimpleDateFormat createDateFromat(Locale locale_p,
                                                String sDateFormat_p)
Create a SimpleDateFormat object. Use this method, to ensure that the date is parsed or formatted on the same manner during OwEditablePropertyDate.insertEditHTML(OwMainAppContext, Locale, Writer, Date, String, boolean, boolean, String) and OwEditablePropertyString.update(Locale, HttpServletRequest) method calls.

Parameters:
locale_p - - the Locale object
sDateFormat_p - - the String object representing the date format.
Returns:
a configured SimpleDateFormat object.
Since:
3.0.0.0

convert

public static Date convert(Date date_p,
                           TimeZone fromTimeZone_p,
                           TimeZone toTimeZone_p)
Converts a given Date represented time stamp from a time zone to another. Although the input parameters and the return value represent dates in different time zones both the given date and the returned date will be expressed in the current time zone (see Date time zone behavior in Java).

Parameters:
date_p - date to be converted
fromTimeZone_p - time zone the date is converted from
toTimeZone_p - time zone the date is converted to
Returns:
the converted date
Since:
3.1.0.3

convertToCalendar

public static Calendar convertToCalendar(Date date_p,
                                         TimeZone fromTimeZone_p,
                                         TimeZone toTimeZone_p)
Convert a date into Calendar representation with specific time zone.

Parameters:
date_p - Date (can be null)
fromTimeZone_p - TimeZone of the provided date
toTimeZone_p - TimeZone of resulting Calendar
Returns:
Calendar with specific calendar, or null if provided date is null
Since:
3.2.0.0

convertToXMLGregorianCalendar

public static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date_p,
                                                                 TimeZone fromTimeZone_p,
                                                                 TimeZone toTimeZone_p)
                                                          throws DatatypeConfigurationException
Convert between defined time zone's and also transform the result into an XMLGregorianCalendar.

Parameters:
date_p - Date to be converted (can be null)
fromTimeZone_p - TimeZone representing date time zone
toTimeZone_p - TimeZone defined resulting time zone
Returns:
XMLGregorianCalendar, or null if provided date is null
Throws:
DatatypeConfigurationException - if could not create DatatypeFactory


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.