ping build

This commit is contained in:
Grahame Grieve 2021-11-22 07:56:44 +11:00
parent bf5c621f43
commit 0dfdb20f2b
3 changed files with 13 additions and 5 deletions

View File

@ -410,7 +410,7 @@ public class DataRenderer extends Renderer {
// dateTimeFormat - application specified format for date times
// null = default to ... depends on mode
// mode - if rendering mode is technical, format defaults to XML format
// locale - otherwise, format defaults to default for the Locale
// locale - otherwise, format defaults to default for the Locale (which defaults to default Locale)
if (isOnlyDate(type.getPrecision())) {
DateTimeFormatter fmt = context.getDateFormat();
if (fmt == null) {
@ -430,7 +430,7 @@ public class DataRenderer extends Renderer {
if (context.isTechnicalMode()) {
fmt = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
} else {
fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(context.getLocale());
}
}
ZonedDateTime zdt = ZonedDateTime.parse(type.primitiveValue());

View File

@ -440,8 +440,16 @@ public class RenderingContext {
return mode == ResourceRendererMode.TECHNICAL;
}
public boolean hasLocale() {
return locale != null;
}
public Locale getLocale() {
return locale;
if (locale == null) {
return Locale.getDefault();
} else {
return locale;
}
}
public void setLocale(Locale locale) {

View File

@ -61,8 +61,8 @@ public class NarrativeGeneratorTests {
rc.setDateTimeFormat(null);
rc.setDateFormat(null);
} else {
rc.setDateTimeFormat(DateTimeFormatter.ofLocalizedDateTime(fmt));
rc.setDateFormat(DateTimeFormatter.ofLocalizedDate(fmt));
rc.setDateTimeFormat(DateTimeFormatter.ofLocalizedDateTime(fmt).withLocale(rc.getLocale()));
rc.setDateFormat(DateTimeFormatter.ofLocalizedDate(fmt).withLocale(rc.getLocale()));
}
rc.setMode(mode);