Dates

Date and time related utility functions.

today

Date today = Dates.today();

Returns today’s date as a Date object. Source

returns

Date

todayAsString

String today = Dates.todayAsString("yyyy-MM-dd");

Returns the today’s date as a string formatted as specified by the formatString parameter. Source

formatString

Date formatting pattern.

returns

String

todayAsIsoString

String today = Dates.todayAsIsoString();

Returns today’s date as string formatted in the ISO format: 2020-11-27. Source

returns

String

yesterday

LocalDate yesterday = Dates.yesterday();

Returns yesterday’s date as a LocalDate object. Source

returns

LocalDate

yesterdayAsString

String yesterday = Dates.yesterdayAsString("yyyy-MM-dd");

Returns yesterday’s date as a string formatted according to the given format string. Source

formatString

Date formatting pattern.

returns

String

yesterdayAsIsoString

String yesterday = Dates.yesterdayAsIsoString();

Returns yesterday’s date as a string formatted in ISO format. 2020-11-27. Source

returns

String

tomorrow

LocalDate tomorrow = Dates.tomorrow();

Returns tomorrow’s date as a LocalDate object. Source

returns

LocalDate

tomorrowAsString

String tomorrow = Dates.tomorrowAsString("yyyy-MM-dd");

Returns tomorrow’s date as a string formatted according to the given format string. Source

formatString

Date formatting pattern.

returns

String

tomorrowAsIsoString

String tomorrow = Dates.tomorrowAsIsoString();

Returns tomorrow’s date as a string formatted in ISO format. 2020-11-27. Source

returns

String

getDaysBetweenDates

long diffInDays = Dates.getDaysBetweenDates("2020-11-03", "2020-12-15");

Gets the number of days between two dates. Source

startDate

Start date as string.

endDate

End date as string.

returns

String