java.time.format.DateTimeFormatter.getLocale()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中java.time.format.DateTimeFormatter.getLocale()方法的一些代码示例,展示了DateTimeFormatter.getLocale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTimeFormatter.getLocale()方法的具体详情如下:
包路径:java.time.format.DateTimeFormatter
类名称:DateTimeFormatter
方法名:getLocale

DateTimeFormatter.getLocale介绍

[英]Gets the locale to be used during formatting.

This is used to lookup any part of the formatter needing specific localization, such as the text or localized pattern.
[中]获取格式化期间要使用的区域设置。
这用于查找需要特定本地化的格式化程序的任何部分,例如文本或本地化模式。

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

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

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public Locale locale() {
  return this.printer.getLocale();
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

private static DateTimeFormatter getSafeDateTimeFormatter(final String pattern) {
  DateTimeFormatter safeFormatter = getDateTimeFormatter(pattern);
  if (Locale.UK.equals(safeFormatter.getLocale())) {
    return safeFormatter.withLocale(Locale.ENGLISH);
  }
  return safeFormatter;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

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

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public Locale getLocale() {
  return this.printer.getLocale();
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Locale getLocale() {
  return this.printer.getLocale();
}

代码示例来源:origin: apache/sis

/**
 * 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;
}

代码示例来源:origin: apache/sis

/**
 * 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;
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * 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();
}

代码示例来源:origin: apache/servicemix-bundles

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

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

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

代码示例来源:origin: horrorho/LiquidDonkey

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

代码示例来源:origin: com.jfoenix/jfoenix

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

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * 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());
}

相关文章