Dates

uk.gov.hmrc.play.language.LanguageUtils.Dates
See theDates companion trait
object Dates extends Dates

Helper object to correctly display and format dates in both English and Welsh.

This object provides a default implementation of the Dates trait in order to provide support for Welsh and English dates.

Attributes

Companion
trait
Graph
Supertypes
trait Dates
class Object
trait Matchable
class Any
Self type
Dates.type

Members list

Value members

Concrete methods

override def defaultTimeZone: TimeZone

The timezone to use when formatting dates

The timezone to use when formatting dates

Attributes

Definition Classes
override def plural(implicit messages: Messages): String

The value of the plural of the word 'day' *

The value of the plural of the word 'day' *

Attributes

Definition Classes
override def singular(implicit messages: Messages): String

The value of the singular of the word 'day' *

The value of the singular of the word 'day' *

Attributes

Definition Classes
override def to(implicit messages: Messages): String

The value of the word 'to' *

The value of the word 'to' *

Attributes

Definition Classes

Inherited methods

def formatDate(date: Option[LocalDate], default: String)(implicit messages: Messages): String

Converts an Option java.time.LocalDate object into a String with the format "D MMMM Y"

Converts an Option java.time.LocalDate object into a String with the format "D MMMM Y"

This function will return a translated string based on the implicit lang object that is passed through with it. If the option is None then the default value is returned back to the caller.

Lang("en") example: 25 January 2015 Lang("cy") example: 25 Ionawr 2015 None example: default

Value parameters

date

The Optional java.time.LocalDate object to convert.

default

A default value to return if the date option is not set.

messages

The implicit lang object.

Attributes

Returns

Either the date as a "D MMMM Y" formatted string or the default value if not set.

Inherited from:
Dates
def formatDate(date: LocalDate)(implicit messages: Messages): String

Converts a java.time.LocalDate object into a String with the format "D MMMM Y".

Converts a java.time.LocalDate object into a String with the format "D MMMM Y".

This function will return a translated string based on the implicit lang object that is passed through with it.

Lang("en") example: 25 January 2015 Lang("cy") example: 25 Ionawr 2015

Value parameters

date

The java.time.LocalDate object to convert.

messages

The implicit lang object.

Attributes

Returns

The date as a "D MMMM Y" formatted string.

Inherited from:
Dates
def formatDateAbbrMonth(date: LocalDate)(implicit messages: Messages): String

Converts a java.time.LocalDate object into a human readable String with the format "D MMM Y"

Converts a java.time.LocalDate object into a human readable String with the format "D MMM Y"

This function will return a translated string based on the implicit lang object that is passed through with it.

Lang("en") example: 25 Jan 2015 Lang("cy") example: 25 Ion 2015

Value parameters

date

The java.time.LocalDate object to convert.

messages

The implicit lang object.

Attributes

Returns

The date as a "D MMM Y" formatted string.

Inherited from:
Dates
def formatDateRange(startDate: LocalDate, endDate: LocalDate)(implicit messages: Messages): String

Converts two java.time.LocalDate objects into a human readable String to show a date range.

Converts two java.time.LocalDate objects into a human readable String to show a date range.

This function will return a translated string based on the implicit lang object.

Lang("en") example: "25 January 2015 to 25 January 2015" Lang("cy") example: "25 Ionawr 2015 i 25 Ionawr 2015"

Value parameters

endDate

The second date.

messages

The implicit lang value.

startDate

The first date.

Attributes

Returns

A string in the format of "D MMMM Y to D MMMM Y"

Inherited from:
Dates
def formatDays(numberOfDays: Int)(implicit messages: Messages): String

Converts an Int into a string appended by 'days'.

Converts an Int into a string appended by 'days'.

This function will return a translated string based on the implicit lang object. It checks to see if the number of days is equal to 1 or not, and then responds with the correct plural or singular value for the word "day".

1, Lang("en") example: 1 day 5, Lang("en") example: 5 days

Value parameters

messages
  • The implicit language object.
numberOfDays
  • The number of days.

Attributes

Returns

A string denoting "x" days.

Inherited from:
Dates
def formatEasyReadingTimestamp(date: Option[LocalDateTime], default: String)(implicit messages: Messages): String

Converts an optional DateTime object into a human readable String with the format: "h:mmaa, EEEE d MMMM yyyy"

Converts an optional DateTime object into a human readable String with the format: "h:mmaa, EEEE d MMMM yyyy"

This function will return a translated string based on the implicit lang object that is passed through with it. If the option is None then the default value is returned back to the caller.

Lang("en") example: "3:45am, Sunday 25 January 2015" Lang("cy" example: "3:45am, Dydd Sul 25 Ionawr 2015"

Value parameters

date

The optional java.time.LocalDateTime object to convert.

default

The default value to return if the date is missing.

messages

The implicit lang object.

Attributes

Returns

The date and time as a "h:mmaa, EEEE d MMMM yyyy" formatted string.

Inherited from:
Dates
def shortDate(date: LocalDate)(implicit messages: Messages): String

Converts a java.time.LocalDate object into a human readable String with the format: "yyyy-MM-dd"

Converts a java.time.LocalDate object into a human readable String with the format: "yyyy-MM-dd"

This function will return a translated string based on the implicit lang object that is passed through with it.

Lang("en") example: 2015-01-25 Lang("cy") example: 2015-01-25

Value parameters

date
  • The java.time.LocalDate object to be converted.
messages
  • The implicit language object.

Attributes

Returns

The date as a "yyyy-MM-dd" formatted string.

Inherited from:
Dates