Added support for Localization
This commit is contained in:
parent
b3930804c6
commit
79fcc243de
1 changed files with 11 additions and 1 deletions
|
@ -19,6 +19,10 @@ package rife.render;
|
|||
|
||||
import rife.template.Template;
|
||||
import rife.template.ValueRenderer;
|
||||
import rife.tools.Localization;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* <p>Renders the current year.</p>
|
||||
|
@ -34,11 +38,17 @@ import rife.template.ValueRenderer;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class Year implements ValueRenderer {
|
||||
/**
|
||||
* Year formatter.
|
||||
*/
|
||||
static public final DateTimeFormatter yearFormatter =
|
||||
DateTimeFormatter.ofPattern("yyyy").withLocale(Localization.getLocale());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String render(Template template, String valueId, String differentiator) {
|
||||
return java.time.Year.now().toString();
|
||||
return ZonedDateTime.now().format(yearFormatter);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue