@Component(value="ui_DateFormatter") @Scope(value="prototype") public class DateFormatter extends java.lang.Object implements Formatter<java.util.Date>
Date
formatter to be used in screen descriptors and controllers.
This formatter formats the Date
value into a string depending on the format string.
Modifier and Type | Field and Description |
---|---|
protected io.jmix.core.security.CurrentAuthentication |
currentAuthentication |
protected java.lang.String |
format |
protected io.jmix.core.metamodel.datatype.FormatStringsRegistry |
formatStringsRegistry |
protected io.jmix.core.Messages |
messages |
protected java.lang.String |
type |
protected boolean |
useUserTimezone |
Constructor and Description |
---|
DateFormatter() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
apply(java.util.Date value) |
void |
setFormat(java.lang.String format)
Sets the format string describing the date format which will be used to create
SimpleDateFormat instance. |
void |
setType(java.lang.String type)
Sets the formatter type, which can have a
DATE or DATETIME value. |
void |
setUseUserTimezone(boolean useUserTimezone)
Sets whether formatter should display the date and time in the current user's timezone.
|
@Autowired protected io.jmix.core.security.CurrentAuthentication currentAuthentication
@Autowired protected io.jmix.core.Messages messages
@Autowired protected io.jmix.core.metamodel.datatype.FormatStringsRegistry formatStringsRegistry
protected java.lang.String format
protected java.lang.String type
protected boolean useUserTimezone
public void setFormat(java.lang.String format)
SimpleDateFormat
instance.
It can be either a format string, or a key in message group.format
- a format string or a key in message grouppublic void setType(java.lang.String type)
DATE
or DATETIME
value. If specified,
the value will be formatted by means of DateDatatype
or DateTimeDatatype
respectively.type
- a formatter typepublic void setUseUserTimezone(boolean useUserTimezone)
useUserTimezone
- true
if the formatter displays the date and time in the current user's timezone,
false
otherwise@Nullable public java.lang.String apply(@Nullable java.util.Date value)
apply
in interface java.util.function.Function<java.util.Date,java.lang.String>