Added support for Localization

This commit is contained in:
Erik C. Thauvin 2023-03-15 23:36:58 -07:00
parent b3930804c6
commit 79fcc243de

View file

@ -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);
}
}