Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class SimpleDateFormat
- Object
- Format
- DateFormat
- SimpleDateFormat
ImplementsCloneable
A class for parsing and formatting dates with a given pattern, compatible with the Java 6 API, as in the examples here: https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
To localize the formatted dates, see the discussion Format a localized date in Codename One.
Constructors
public SimpleDateFormat() | Construct a SimpleDateFormat with no pattern. |
public SimpleDateFormat(String pattern) | Construct a SimpleDateFormat with a given pattern. |
Methods
Inherited fields
Inherited methods
Constructor details
SimpleDateFormat
public SimpleDateFormat()SimpleDateFormat
public SimpleDateFormat(String pattern)Method details
isRestrictMonthNameLength
public static boolean isRestrictMonthNameLength()Returns
true if localized month names should be truncated to the
requested pattern length.setRestrictMonthNameLength
public static void setRestrictMonthNameLength(boolean restrict)Parameters
restrictbooleantrueto truncate localized month names to the length requested by the pattern,falseto keep the platform provided value as-is (default behaviour).
toPattern
public String toPattern()Returns
getDateFormatSymbols
public DateFormatSymbols getDateFormatSymbols()Returns
setDateFormatSymbols
public void setDateFormatSymbols(DateFormatSymbols newSymbols)Parameters
newSymbolsDateFormatSymbols- new format symbols.
applyPattern
public void applyPattern(String pattern)Parameters
patternString- the pattern to set
equals
public boolean equals(Object o)hashCode
public int hashCode()clone
public Object clone()setTimeZone
public void setTimeZone(TimeZone zone)Sets the time zone the date’s fields are formatted in, as java.text.DateFormat
does. Without one the device’s default zone is used.
A formatter fixed to the device zone cannot print an instant’s fields in any other: a UTC time had to be moved onto a local one first, and inside a daylight-saving gap that local time does not exist, so its hour came out shifted.
Parameters
zoneTimeZone- the zone, or null for the device’s default
getTimeZone
public TimeZone getTimeZone()setTimeZone, or the zone captured at construction when
none was set.Returns
format
public String format(Date source)Parameters
sourceDate- date to be formatted.
Returns
parse
public Date parse(String source)
throws ParseException