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

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

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

DateTimeFormatter.<init>介绍

[英]Constructor.
[中]构造器。

代码示例

代码示例来源:origin: com.jtransc/jtransc-rt

public static DateTimeFormatter ofLocalizedTime(FormatStyle timeStyle) {
  return new DateTimeFormatter();
}

代码示例来源:origin: com.jtransc/jtransc-rt

public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateTimeStyle) {
  return new DateTimeFormatter();
}

代码示例来源:origin: com.jtransc/jtransc-rt

public static DateTimeFormatter ofPattern(String pattern, Locale locale) {
  return new DateTimeFormatter();
}

代码示例来源:origin: com.jtransc/jtransc-rt

public static DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle) {
  return new DateTimeFormatter();
}

代码示例来源:origin: com.jtransc/jtransc-rt

public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateStyle, FormatStyle timeStyle) {
  return new DateTimeFormatter();
}

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

/**
 * Returns a copy of this formatter with a new locale.
 * <p>
 * This is used to lookup any part of the formatter needing specific
 * localization, such as the text or localized pattern.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param locale  the new locale, not null
 * @return a formatter based on this formatter with the requested locale, not null
 */
public DateTimeFormatter withLocale(Locale locale) {
  if (this.locale.equals(locale)) {
    return this;
  }
  return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}

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

/**
 * Returns a copy of this formatter with a new decimal style.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param decimalStyle  the new decimal style, not null
 * @return a formatter based on this formatter with the requested symbols, not null
 */
public DateTimeFormatter withDecimalStyle(DecimalStyle decimalStyle) {
  if (this.decimalStyle.equals(decimalStyle)) {
    return this;
  }
  return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}

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

return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, null, chrono, zone);
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);

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

/**
 * Returns a copy of this formatter with a new override chronology.
 * <p>
 * This returns a formatter with similar state to this formatter but
 * with the override chronology set.
 * By default, a formatter has no override chronology, returning null.
 * <p>
 * If an override is added, then any date that is printed or parsed will be affected.
 * <p>
 * When printing, if the {@code Temporal} object contains a date then it will
 * be converted to a date in the override chronology.
 * Any time or zone will be retained unless overridden.
 * The converted result will behave in a manner equivalent to an implementation
 * of {@code ChronoLocalDate},{@code ChronoLocalDateTime} or {@code ChronoZonedDateTime}.
 * <p>
 * When parsing, the override chronology will be used to interpret the
 * {@linkplain ChronoField fields} into a date unless the
 * formatter directly parses a valid chronology.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param chrono  the new chronology, not null
 * @return a formatter based on this formatter with the requested override chronology, not null
 */
public DateTimeFormatter withChronology(Chronology chrono) {
  if (Jdk8Methods.equals(this.chrono, chrono)) {
    return this;
  }
  return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}

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

return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, null, chrono, zone);
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, fields, chrono, zone);

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

return this;
return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);

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

/**
 * Returns a copy of this formatter with a new resolver style.
 * <p>
 * This returns a formatter with similar state to this formatter but
 * with the resolver style set. By default, a formatter has the
 * {@link ResolverStyle#SMART SMART} resolver style.
 * <p>
 * Changing the resolver style only has an effect during parsing.
 * Parsing a text string occurs in two phases.
 * Phase 1 is a basic text parse according to the fields added to the builder.
 * Phase 2 resolves the parsed field-value pairs into date and/or time objects.
 * The resolver style is used to control how phase 2, resolving, happens.
 * See {@code ResolverStyle} for more information on the options available.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param resolverStyle  the new resolver style, not null
 * @return a formatter based on this formatter with the requested resolver style, not null
 */
public DateTimeFormatter withResolverStyle(ResolverStyle resolverStyle) {
  Jdk8Methods.requireNonNull(resolverStyle, "resolverStyle");
  if (Jdk8Methods.equals(this.resolverStyle, resolverStyle)) {
    return this;
  }
  return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone);
}

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

/**
 * Completes this builder by creating the DateTimeFormatter using the specified locale.
 * <p>
 * This will create a formatter with the specified locale.
 * Numbers will be printed and parsed using the standard non-localized set of symbols.
 * <p>
 * Calling this method will end any open optional sections by repeatedly
 * calling {@link #optionalEnd()} before creating the formatter.
 * <p>
 * This builder can still be used after creating the formatter if desired,
 * although the state may have been changed by calls to {@code optionalEnd}.
 *
 * @param locale  the locale to use for formatting, not null
 * @return the created formatter, not null
 */
public DateTimeFormatter toFormatter(Locale locale) {
  Jdk8Methods.requireNonNull(locale, "locale");
  while (active.parent != null) {
    optionalEnd();
  }
  CompositePrinterParser pp = new CompositePrinterParser(printerParsers, false);
  return new DateTimeFormatter(pp, locale, DecimalStyle.STANDARD, ResolverStyle.SMART, null, null, null);
}

相关文章