private void updateDayNameCells() { int weekFirstDay = WeekFields.of(getLocale()).getFirstDayOfWeek().getValue(); LocalDate date = LocalDate.of(2009, 7, 12 + weekFirstDay); for (int i = 0; i < daysPerWeek; i++) { String name = weekDayNameFormatter.withLocale(getLocale()).format(date.plus(i, DAYS)); // Fix Chinese environment week display incorrectly // Take the last character of the Chinese weekday names if (weekDayNameFormatter.getLocale() == java.util.Locale.CHINA) { name = name.substring(name.length() - 1).toUpperCase(); } else { name = name.substring(0, 1).toUpperCase(); } weekDaysCells.get(i).setText(name); } }
@Override public Locale locale() { return this.printer.getLocale(); }
private static DateTimeFormatter getSafeDateTimeFormatter(final String pattern) { DateTimeFormatter safeFormatter = getDateTimeFormatter(pattern); if (Locale.UK.equals(safeFormatter.getLocale())) { return safeFormatter.withLocale(Locale.ENGLISH); } return safeFormatter; }
@Override public DateFormatter withLocale(Locale locale) { // shortcurt to not create new objects unnecessarily if (locale.equals(parsers[0].getLocale())) { return this; } final DateTimeFormatter[] parsersWithZone = new DateTimeFormatter[parsers.length]; for (int i = 0; i < parsers.length; i++) { parsersWithZone[i] = parsers[i].withLocale(locale); } return new JavaDateFormatter(format, printer.withLocale(locale), parsersWithZone); }
@Override public Locale getLocale() { return this.printer.getLocale(); }
@Override public Locale getLocale() { return this.printer.getLocale(); }
/** * Returns the number format, creating it when first needed. This {@code StandardDateFormat} class does not use the * number format, but we nevertheless create it if requested in order to comply with {@code DateFormat} contract. * * @return a number format, created when first needed. */ @Override public final NumberFormat getNumberFormat() { if (numberFormat == null) { numberFormat = NumberFormat.getInstance(format.getLocale()); } return numberFormat; }
/** * Returns the calendar, creating it when first needed. This {@code StandardDateFormat} class does not use the * calendar, but we nevertheless create it if requested in order to comply with {@code DateFormat} contract. * * @return a calendar, created when first needed. */ @Override public final Calendar getCalendar() { if (calendar == null) { calendar = Calendar.getInstance(getTimeZone(), format.getLocale()); } return calendar; }
/** * Creates a new instance of the context. * * @param temporal the temporal object being output, not null * @param formatter the formatter controlling the print, not null */ DateTimePrintContext(TemporalAccessor temporal, DateTimeFormatter formatter) { super(); this.temporal = adjust(temporal, formatter); this.locale = formatter.getLocale(); this.symbols = formatter.getDecimalStyle(); }
@Override public DateFormatter withLocale(Locale locale) { // shortcurt to not create new objects unnecessarily if (locale.equals(parsers[0].getLocale())) { return this; } final DateTimeFormatter[] parsersWithZone = new DateTimeFormatter[parsers.length]; for (int i = 0; i < parsers.length; i++) { parsersWithZone[i] = parsers[i].withLocale(locale); } return new JavaDateFormatter(format, printer.withLocale(locale), parsersWithZone); }
@Override public DateFormatter withLocale(Locale locale) { // shortcurt to not create new objects unnecessarily if (locale.equals(parsers[0].getLocale())) { return this; } final DateTimeFormatter[] parsersWithZone = new DateTimeFormatter[parsers.length]; for (int i = 0; i < parsers.length; i++) { parsersWithZone[i] = parsers[i].withLocale(locale); } return new JavaDateFormatter(format, printer.withLocale(locale), parsersWithZone); }
public static BackupFormatter create(String indent, DateTimeFormatter dateTimeFormatter) { if (dateTimeFormatter.getLocale() == null) { dateTimeFormatter = dateTimeFormatter.withLocale(Locale.getDefault()); } if (dateTimeFormatter.getZone() == null) { dateTimeFormatter = dateTimeFormatter.withZone(ZoneId.systemDefault()); } return new BackupFormatter(indent, dateTimeFormatter); }
private void updateDayNameCells() { int weekFirstDay = WeekFields.of(getLocale()).getFirstDayOfWeek().getValue(); LocalDate date = LocalDate.of(2009, 7, 12 + weekFirstDay); for (int i = 0; i < daysPerWeek; i++) { String name = weekDayNameFormatter.withLocale(getLocale()).format(date.plus(i, DAYS)); // Fix Chinese environment week display incorrectly if (weekDayNameFormatter.getLocale() == java.util.Locale.CHINA) { name = name.substring(2, 3).toUpperCase(); } else { name = name.substring(0, 1).toUpperCase(); } weekDaysCells.get(i).setText(name); } }
/** * Creates a new instance of the context. * * @param formatter the formatter controlling the parse, not null */ DateTimeParseContext(DateTimeFormatter formatter) { super(); this.locale = formatter.getLocale(); this.symbols = formatter.getDecimalStyle(); this.overrideChronology = formatter.getChronology(); this.overrideZone = formatter.getZone(); parsed.add(new Parsed()); }