|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.oozie.util.DateUtils
public class DateUtils
Date utility classes to parse and format datetimes in Oozie expected datetime formats.
Field Summary | |
---|---|
static String |
ISO8601_UTC_MASK
|
static String |
OOZIE_PROCESSING_TIMEZONE_DEFAULT
|
static String |
OOZIE_PROCESSING_TIMEZONE_KEY
|
static TimeZone |
UTC
|
Constructor Summary | |
---|---|
DateUtils()
|
Method Summary | |
---|---|
static Timestamp |
convertDateToTimestamp(Date d)
Convert java.util.Date to java.sql.Timestamp |
static String |
formatDateCustom(Date d,
String format)
Formats a Date as a string using the specified format mask. |
static String |
formatDateOozieTZ(Calendar c)
Formats a Calendar as a string in ISO8601 format using Oozie processing timezone. |
static String |
formatDateOozieTZ(Date d)
Formats a Date as a string in ISO8601 format using Oozie processing timezone. |
static Calendar |
getCalendar(String dateString)
Create a Calendar instance for UTC time zone using the specified date. |
static Calendar |
getCalendar(String dateString,
TimeZone tz)
Create a Calendar instance using the specified date and Time zone |
static TimeZone |
getOozieProcessingTimeZone()
Returns Oozie processing timezone. |
static String |
getOozieTimeMask()
Returns Oozie processing datetime mask. |
static TimeZone |
getTimeZone(String tzId)
Returns the TimeZone for the given timezone ID. |
static int |
hoursInDay(Calendar cal)
This function returns number of hour in a day when given a Calendar with appropriate TZ. |
static boolean |
isDSTChangeDay(Calendar cal)
Determine whether a specific date is on DST change day |
static void |
moveToEnd(Calendar cal,
TimeUnit endOfFlag)
Move the any date-time to the end of the duration. |
static Date |
parseDateOozieTZ(String s)
Parses a datetime in ISO8601 format in the Oozie processing timezone. |
static Date |
parseDateUTC(String s)
Parses a datetime in ISO8601 format in UTC timezone |
static void |
setConf(org.apache.hadoop.conf.Configuration conf)
Configures the Datetime parsing with Oozie processing timezone. |
static Date |
toDate(Timestamp timestamp)
Convert java.sql.Timestamp to java.util.Date |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final TimeZone UTC
public static final String ISO8601_UTC_MASK
public static final String OOZIE_PROCESSING_TIMEZONE_KEY
public static final String OOZIE_PROCESSING_TIMEZONE_DEFAULT
Constructor Detail |
---|
public DateUtils()
Method Detail |
---|
public static void setConf(org.apache.hadoop.conf.Configuration conf)
OOZIE_PROCESSING_TIMEZONE_KEY
property is read and set as the Oozie processing timezone.
Valid values for this property are UTC
and GMT(+/-)####
conf
- Oozie server configuration.public static TimeZone getOozieProcessingTimeZone()
UTC
or a GMT(+/-)####
timezone.public static String getOozieTimeMask()
public static TimeZone getTimeZone(String tzId)
TimeZone
for the given timezone ID.
tzId
- timezone ID.
TimeZone
for the given timezone ID.public static Date parseDateUTC(String s) throws ParseException
s
- string with the datetime to parse.
Date
instance for the parsed date.
ParseException
- thrown if the given string was not an ISO8601 UTC value.public static Date parseDateOozieTZ(String s) throws ParseException
s
- string with the datetime to parse.
Date
instance for the parsed date.
ParseException
- thrown if the given string was not an ISO8601 value for the Oozie processing timezon.public static String formatDateOozieTZ(Date d)
Date
as a string in ISO8601 format using Oozie processing timezone.
d
- Date
to format.
NULL
if the Date
instance was
NULL
public static String formatDateCustom(Date d, String format)
Date
as a string using the specified format mask.
The format mask must be a SimpleDateFormat
valid format mask.
d
- Date
to format.
NULL
if the Date
instance was NULL
public static String formatDateOozieTZ(Calendar c)
Calendar
as a string in ISO8601 format using Oozie processing timezone.
c
- Calendar
to format.
NULL
if the Calendar
instance was
NULL
public static int hoursInDay(Calendar cal)
cal:
- The date for which the number of hours is requested
public static boolean isDSTChangeDay(Calendar cal)
cal:
- Date to know if it is DST change day. Appropriate TZ is specified
public static void moveToEnd(Calendar cal, TimeUnit endOfFlag)
cal
- : Date-time needs to be moved to the endendOfFlag
- : day (for end of day) or month (for end of month) or emptypublic static Calendar getCalendar(String dateString, TimeZone tz) throws Exception
dateString
- tz
- : TimeZone
Exception
public static Calendar getCalendar(String dateString) throws Exception
dateString
-
Exception
public static Date toDate(Timestamp timestamp)
timestamp
- java.sql.Timestamp
public static Timestamp convertDateToTimestamp(Date d)
d
- java.util.Date
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |