Package nl.gx.forms.wmpformapi.engine
Class FormDate
- java.lang.Object
-
- nl.gx.forms.wmpformapi.engine.FormDate
-
public class FormDate extends Object
Represents a date value submiited in a form.- Since:
- 10.33.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Locale
createProperLocale(String formLocaleString)
String
getIsoFormat()
Get the ISO representation.String
toLocaleString(Locale locale)
Format the ISO string to some locale specified by the parameterString
toString()
toString method should return the formatted String as defined by the locale of the form.boolean
validIsoDate()
Check whether the String supplied to the constructor is of format 'yyyy-MM-dd'.
-
-
-
Constructor Detail
-
FormDate
public FormDate(String isoString, Locale locale)
Creating a form date should involve the locale of the form and the ISO string (ISO-8601), yyyy-MM-dd. https://www.iso.org/iso-8601-date-and-time-format.html- Parameters:
isoString
- the ISO-8601 string representing the datelocale
- locale of the form scope, the ISO date will get formatted to this locale. The Locale should include a country and language tag.
-
-
Method Detail
-
toLocaleString
public String toLocaleString(Locale locale)
Format the ISO string to some locale specified by the parameter- Parameters:
locale
- the locale to format the internal ISO string to- Returns:
- String representing date formatted to the argument locale
-
getIsoFormat
public String getIsoFormat()
Get the ISO representation.- Returns:
- String representing internal ISO String.
-
createProperLocale
public static Locale createProperLocale(String formLocaleString)
- Parameters:
formLocaleString
- the String of the form scope representing the locale in the format: "language_COUNTRY" ("en_US")- Returns:
- Locale with proper fields, both country tag and language tag
-
validIsoDate
public boolean validIsoDate()
Check whether the String supplied to the constructor is of format 'yyyy-MM-dd'. Should always be true since internal representations are ISO Strings.- Returns:
- boolean indicating a valid internal ISO String
-
toString
public String toString()
toString method should return the formatted String as defined by the locale of the form. This method is called when accessing the value of the object in the Form scope.- Overrides:
toString
in classObject
- Returns:
- String representing date formatted to submitted locale from
toSubmittedLocaleString()
.
-
-