public class DateUtil
extends java.lang.Object
Constructor and Description |
---|
DateUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.Calendar |
createCalendar(java.util.Date date) |
static java.util.List<java.lang.String> |
createTimeValues(java.util.Date dateFrom,
java.util.Date dateTo,
TIME_FORMAT format)
Creates a list of all the date values between the from and to dates.
|
static javax.xml.datatype.XMLGregorianCalendar |
createXMLGregorianCalendar(java.util.Date date) |
static java.lang.String |
formatDate(java.util.Date dt) |
static java.lang.String |
formatDate(java.util.Date date,
TIME_FORMAT format)
Return an SDMX-ML formatted time period, based on the frequency supplied.
|
static java.util.Date |
formatDate(java.lang.Object dateObject,
boolean startOfPeriod)
Formats a String as a date.
|
static java.lang.String |
formatDateForSdmxVersion1(java.lang.String aDate)
SDMX 1.0 does not support quarterly dates (2001-Q1) or half-yearly dates (2001-S1) and these
must be converted into monthly dates where:
Q1 is month 01
Q2 is month 04
Q3 is month 07
Q4 is month 10
S1 is month 01
S2 is month 07
|
static java.lang.String |
formatDateForSdmxVersion2(java.lang.String aDate)
SDMX 2.1 represents Bi-annual dates as [0-9][0-9][0-9][0-9]-S[1-2] e.g.
|
static java.lang.String |
formatDateForSdmxVersion21(java.lang.String aDate)
SDMX 2.1 represents Bi-annual dates as [0-9][0-9][0-9][0-9]-S[1-2] e.g.
|
static java.util.Calendar |
getCalendar()
This method should be used instead of
Calendar.getInstance() since it
constructs a Calendar with the appropriate default settings which ensures Dates are calculated correctly. |
static java.util.Calendar |
getCalendar(int calfield,
int num)
Returns a calendar which is initialized with date now() +/- the time given in the calfield, obtained from Calendar.[Feild]
and the time.
|
static java.text.DateFormat |
getDateFormat() |
static java.text.DateFormat |
getDateFormatter(java.lang.String pattern)
Returns a DateFormat object which has its TimeZone set to GMT.
|
static java.text.DateFormat |
getDateTimeFormat()
Returns a DateFormat object that can be used to format a date
string as a date object.
|
static java.lang.String |
getDateTimeStringNow() |
static java.util.Date |
getEndOfDay(java.util.Date date)
Returns the end of the day (23:59:59:999) for the supplied date and returns a new date instance.
|
static java.text.DateFormat |
getMonthFormat() |
static TIME_FORMAT |
getTimeFormatOfDate(java.lang.String dateStr)
Validates the date is in SDMX date/time format, and returns the Time Format for the date
|
static java.text.DateFormat |
getYearFormat() |
static java.text.DateFormat |
geWeekFormat() |
static boolean |
isSdmxDate(java.lang.String dateStr)
Returns true if the input string can be expressed as an SDMX date, false if not
|
static java.util.Date |
moveToEndofPeriod(java.util.Date date,
TIME_FORMAT timeFormat)
Returns the end value for the specified date.
|
static java.util.Date |
parseDate(java.lang.String date,
java.lang.String dateFormat) |
public static java.util.Calendar getCalendar(int calfield, int num)
calfield
- num
- public static java.util.Calendar createCalendar(java.util.Date date)
public static javax.xml.datatype.XMLGregorianCalendar createXMLGregorianCalendar(java.util.Date date)
public static java.util.Date moveToEndofPeriod(java.util.Date date, TIME_FORMAT timeFormat)
date
- the date to analysetimeFormat
- The timeFormat to use.public static java.util.Date formatDate(java.lang.Object dateObject, boolean startOfPeriod)
dateObject
- startOfPeriod
- formats the date to the start of the period, otherwise it will be end of periodpublic static boolean isSdmxDate(java.lang.String dateStr)
dateString
- public static TIME_FORMAT getTimeFormatOfDate(java.lang.String dateStr)
dateStr
- javax.xml.bind.ValidationException
- if the data format is invalid, with regards to the allowed SDMX date formatspublic static java.lang.String formatDate(java.util.Date dt)
public static java.text.DateFormat getDateTimeFormat()
public static java.text.DateFormat getDateFormat()
public static java.text.DateFormat getYearFormat()
public static java.text.DateFormat getMonthFormat()
public static java.text.DateFormat geWeekFormat()
public static java.util.List<java.lang.String> createTimeValues(java.util.Date dateFrom, java.util.Date dateTo, TIME_FORMAT format)
dateFrom
- dateTo
- format
- public static java.lang.String formatDate(java.util.Date date, TIME_FORMAT format)
date
- the date to convertfreq
- the frequency on which the conversion should be basedTimePeriodType
format.public static java.lang.String getDateTimeStringNow()
public static java.util.Calendar getCalendar()
Calendar.getInstance()
since it
constructs a Calendar with the appropriate default settings which ensures Dates are calculated correctly.
The use of a Calendar with TimeZone of GMT is important since GMT is NOT a TimeZone
that has any daylight saving hours issues.public static java.util.Date getEndOfDay(java.util.Date date)
date
- public static java.util.Date parseDate(java.lang.String date, java.lang.String dateFormat)
public static java.text.DateFormat getDateFormatter(java.lang.String pattern)
public static java.lang.String formatDateForSdmxVersion21(java.lang.String aDate)
aDate
- public static java.lang.String formatDateForSdmxVersion2(java.lang.String aDate)
aDate
- public static java.lang.String formatDateForSdmxVersion1(java.lang.String aDate)