public class DateTimeUtils
extends java.lang.Object
Constructor and Description |
---|
DateTimeUtils() |
Modifier and Type | Method and Description |
---|---|
static java.util.Date |
createDate(int year,
int month,
int day)
Helper method used to create a new Date object.
|
static java.util.Date |
createDate(int year,
int month,
int day,
int hours,
int minutes,
int seconds)
Helper method used to create a new Date object.
|
static java.util.Date |
createDate(long secondsFromEpoch)
Helper method used to convert seconds from epoch to a new Date object.
|
static java.lang.String |
formatDate(java.util.Date date,
BrazeDateFormat dateFormat)
Formats the date using the specified DateFormat pattern in the UTC timezone.
|
static java.lang.String |
formatDate(java.util.Date date,
BrazeDateFormat dateFormat,
java.util.TimeZone timeZone)
Formats the date using the specified DateFormat pattern.
|
static java.lang.String |
formatDateNow(BrazeDateFormat dateFormat)
Formats the current time with the specified format in the current timezone.
|
static long |
getTimeFromEpochInSeconds(java.util.Date date) |
static boolean |
isValidTimeZone(java.lang.String timeZoneId)
Helper method to determine if a timeZoneId is valid
|
static long |
nowInMilliseconds()
Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC (Unix time)
|
static long |
nowInSeconds()
Returns the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC (Unix time)
|
static double |
nowInSecondsPrecise()
Returns the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC (Unix time) with
millisecond precision to 3 places.
|
static java.util.Date |
parseDate(java.lang.String dateString,
BrazeDateFormat dateFormat)
Returns a Date object parsed from an AppboyDateFormat formatted date string.
|
public static long nowInSeconds()
public static double nowInSecondsPrecise()
public static long nowInMilliseconds()
public static java.util.Date parseDate(java.lang.String dateString, BrazeDateFormat dateFormat)
formatDate(Date, BrazeDateFormat)
dateString
- the formatted date stringdateFormat
- the date format pattern of dateStringpublic static java.lang.String formatDate(java.util.Date date, BrazeDateFormat dateFormat)
date
- object to formatdateFormat
- date format patternjava.lang.NullPointerException
- if date is nullpublic static java.lang.String formatDate(java.util.Date date, BrazeDateFormat dateFormat, java.util.TimeZone timeZone)
parseDate(String, BrazeDateFormat)
date
- object to formatdateFormat
- date format patterntimeZone
- The desired timezonejava.lang.NullPointerException
- if date is nullpublic static java.lang.String formatDateNow(BrazeDateFormat dateFormat)
public static java.util.Date createDate(int year, int month, int day)
year
- integer representing the yearmonth
- integer representing the month. The month is 0-based (0 for January, 1 for February, etc)day
- integer representing the day of the monthpublic static java.util.Date createDate(int year, int month, int day, int hours, int minutes, int seconds)
year
- integer representing the yearmonth
- integer representing the month. The month is 0-based (0 for January, 1 for February, etc)day
- integer representing the day of the monthhours
- integer representing the hour of the day. The hour is based on a 24 hour clock (0-23)minutes
- integer representing the minutes of the hour (0-59)seconds
- integer representing the seconds of the minute (0-59)public static java.util.Date createDate(long secondsFromEpoch)
secondsFromEpoch
- integer representing the number of seconds elapsed since the epochpublic static long getTimeFromEpochInSeconds(java.util.Date date)
date
- public static boolean isValidTimeZone(java.lang.String timeZoneId)
timeZoneId
- Time Zone ID candidate