DateTime

Description

Utility functions to operate on DateTime properties

Functions

NameSignature and Synopsis
addDayDateTime addDay (DateTime date, int days)
Adds a number of days to a date and returns the resulting DateTime. The date argument is not modified.
addHourDateTime addHour(DateTime date, int hours)
Adds a number of hours to a date and returns the resulting DateTime. The date argument is not modified.
addMinuteDateTime addMinute (DateTime date, int minutes)
Adds a number of minutes to a date and returns the resulting DateTime. The date argument is not modified.
addMonthDateTime addMonth (DateTime date, int months)
Adds a number of months to a date and returns the resulting DateTime. The date argument is not modified.
addSecondDateTime addSecond (DateTime date, int seconds)
Adds a number of seconds to a date and returns the resulting DateTime. The date argument is not modified.
addWeekDateTime addWeek (DateTime date, int weeks)
Adds a number of weeks to a date and returns the resulting DateTime. The date argument is not modified.
addYearDateTime addYear (DateTime date, int years)
Adds a number of years to a date and returns the resulting DateTime. The date argument is not modified.
afterboolean after (DateTime d1, DateTime d2)
Test if the first DateTime passed come after the second DateTime passed.
beforeboolean before (DateTime d1, DateTime d2)
Test if the first DateTime passed come before the second DateTime passed.
createTimecreateTime(int year, int month, int date, int hrs, int min, int sec, String tz)
Create a DateTime object of a particular timezone.
equalsboolean equals (DateTime d1, DateTime d2)
Is the date time value of first DateTime passed the same as date time value of second DateTime passed.
formatString format (DateTime d1, String format)
Returns the DateTime passed as a formatted String.
getDateint getDate(DateTime date)
Gets the date on the DateTime Object passed as input.
getHourint getHour(DateTime date)
Gets the hour on the DateTime Object passed as input.
getMinuteint getMinute(DateTime date)
Gets the minute on the DateTime Object passed as input.
getMonthint getMonth(DateTime date)
Gets the month on the DateTime Object passed as input. Month value is 0-based. i.e. 0 for January, 11 for December.
getSecondint getSecond(DateTime date)
Gets the second on the DateTime Object passed as input.
getTimeInMillislong getTimeInMillis (DateTime d1)
Returns the time in milliseconds since the start of 1970 GMT.
getTimeZoneString getTimeZone(DateTime date, boolean daylight_saving_name)
Gets timezone id from DateTime object.
getYearint getYear(DateTime date)
Gets the year on the DateTime Object passed as input.
notEqualsboolean notEquals (DateTime d1, DateTime d2)
Tests if the first DateTime is not the same as the second DateTime.
nowDateTime now ()
Returns the current System time as a DateTime.
parseLongDateTime parseLong(long time)
Parses the time in milliseconds since the start of 1970 and return as a DateTime.
parseStringDateTime parseString (String date, String format)
Parses the date provided in the string according to the format and returns it as a DateTime with default time zone.
translateTimeDateTime translateTime(DateTime date, String tz)
Translate a time to a new timezone and return the new translated DateTime object.