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
Modifier and Type | Field and Description |
---|---|
static int |
NUMBER_OF_MONTHS
number of months in year
|
static int |
NUMBER_OF_WEEKDAYS
number of days in a week
|
Constructor and Description |
---|
OwDateTimeUtil() |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final int NUMBER_OF_WEEKDAYS
public static final int NUMBER_OF_MONTHS
public static Date setBeginOfDayTime(Date date_p)
date_p
- Datepublic static Date setBeginOfNextDayTime(Date date_p)
date_p
- Datepublic static Date offsetDay(Date date_p, int iDays_p)
iDays_p
- intpublic static Date offsetDay(Date date_p, int iDays_p, boolean dst_p)
date_p
- base DateiDays_p
- number of days to add to the base date (can be a negative number)dst_p
- if true
a DST adjustment will be performedfalse
absolute time will be usedDate
before of after the given date with the specified amount of dayspublic static Date setEndOfDayTime(Date date_p)
date_p
- Datepublic static String removeTimeFormatTokens(String sDateFormat_p)
public static String removeDateFormatTokens(String sDateFormat_p)
sDateFormat_p
- the date format to be cleared of date tokenspublic static String[] getMonthNames(Locale locale_p)
locale_p
- - the Locale
objectpublic static String[] getShortMonthNames(Locale locale_p)
locale_p
- String
objects, representing the short names for monthspublic static String[] getWeekDays(Locale locale_p)
public static String[] getShortWeekDays(Locale locale_p)
public static SimpleDateFormat createDateFromat(Locale locale_p, String sDateFormat_p)
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.locale_p
- - the Locale
objectsDateFormat_p
- - the String
object representing the date format.SimpleDateFormat
object.public static Date convert(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p)
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).date_p
- date to be convertedfromTimeZone_p
- time zone the date is converted fromtoTimeZone_p
- time zone the date is converted topublic static Calendar convertToCalendar(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p)
date_p
- Date (can be null)fromTimeZone_p
- TimeZone of the provided datetoTimeZone_p
- TimeZone of resulting Calendarpublic static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date_p, TimeZone fromTimeZone_p, TimeZone toTimeZone_p) throws DatatypeConfigurationException
date_p
- Date to be converted (can be null)fromTimeZone_p
- TimeZone representing date time zonetoTimeZone_p
- TimeZone defined resulting time zoneDatatypeConfigurationException
- if could not create DatatypeFactoryCopyright © 2014 Alfresco Business Solutions. All Rights Reserved.