java.time.format.DateTimeFormatterBuilder#getLocalizedDateTimePattern ( )源码实例Demo

下面列出了java.time.format.DateTimeFormatterBuilder#getLocalizedDateTimePattern ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LGoodDatePicker   文件: InternalUtilities.java
/**
 * generateDefaultFormatterBCE, This returns a default formatter for the specified locale, that
 * can be used for displaying or parsing BC dates. The formatter is generated from the default
 * FormatStyle.LONG formatter in the specified locale. The resulting format is intended to be
 * nearly identical to the default formatter used for AD dates.
 */
public static DateTimeFormatter generateDefaultFormatterBCE(Locale pickerLocale) {
    // This is verified to work for the following locale languages:
    // en, de, fr, pt, ru, it, nl, es, pl, da, ro, sv, zh.
    String displayFormatterBCPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(
        FormatStyle.LONG, null, IsoChronology.INSTANCE, pickerLocale);
    displayFormatterBCPattern = displayFormatterBCPattern.replace("y", "u");
    // Note: We could have used DateUtilities.createFormatterFromPatternString(), which should
    // have the same formatter options as this line. We kept this code independent in case
    // anyone ever mistakenly changes that utility function.
    DateTimeFormatter displayFormatterBC = new DateTimeFormatterBuilder().parseLenient()
        .parseCaseInsensitive().appendPattern(displayFormatterBCPattern)
        .toFormatter(pickerLocale);
    // Get the local language as a string.
    String language = pickerLocale.getLanguage();
    // Override the format for the turkish locale to remove the name of the weekday.
    if ("tr".equals(language)) {
        displayFormatterBC = PickerUtilities.createFormatterFromPatternString(
            "dd MMMM uuuu", pickerLocale);
    }
    return displayFormatterBC;
}
 
源代码2 项目: openemm   文件: ComAdminImpl.java
@Override
public DateTimeFormatter getDateTimeFormatterWithSeconds() {
	String dateFormatPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.MEDIUM, IsoChronology.INSTANCE, getLocale());
	dateFormatPattern = dateFormatPattern.replaceFirst("y+", "yyyy").replaceFirst(", ", " ");
	DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormatPattern, getLocale());
	dateTimeFormatter.withZone(TimeZone.getTimeZone(getAdminTimezone()).toZoneId());
	dateTimeFormatter.withResolverStyle(ResolverStyle.STRICT);
	return dateTimeFormatter;
}
 
源代码3 项目: openemm   文件: ComAdminImpl.java
@Override
public DateTimeFormatter getDateTimeFormatter() {
	String dateTimeFormatPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, getLocale());
	dateTimeFormatPattern = dateTimeFormatPattern.replaceFirst("y+", "yyyy").replaceFirst(", ", " ");
	DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateTimeFormatPattern, getLocale());
	dateTimeFormatter.withZone(TimeZone.getTimeZone(getAdminTimezone()).toZoneId());
	dateTimeFormatter.withResolverStyle(ResolverStyle.STRICT);
	return dateTimeFormatter;
}
 
源代码4 项目: j2objc   文件: TestDateTimeFormatterBuilder.java
@Test
@UseDataProvider("localizedDateTimePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals("Pattern " + convertNonAscii(actual), actual, expected);
}
 
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedChronoNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US);
}
 
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedChronoNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US);
}
 
源代码8 项目: hottub   文件: TestDateTimeFormatterBuilder.java
@Test(expectedExceptions=java.lang.IllegalArgumentException.class)
public void test_getLocalizedDateTimePatternIAE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(null, null, IsoChronology.INSTANCE, Locale.US);
}
 
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedLocaleNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null);
}
 
源代码11 项目: jdk8u-jdk   文件: TestDateTimeFormatterBuilder.java
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedLocaleNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null);
}
 
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedLocaleNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null);
}
 
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
源代码14 项目: jdk8u60   文件: TestDateTimeFormatterBuilder.java
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedChronoNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US);
}
 
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
源代码16 项目: hottub   文件: TestDateTimeFormatterBuilder.java
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
源代码17 项目: jdk8u-jdk   文件: TestDateTimeFormatterBuilder.java
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedChronoNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US);
}
 
@Test(expectedExceptions=java.lang.NullPointerException.class)
public void test_getLocalizedLocaleNPE() {
    DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null);
}
 
@Test(dataProvider="localePatterns")
public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale, String expected) {
    String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale);
    assertEquals(actual, expected, "Pattern " + convertNonAscii(actual));
}
 
源代码20 项目: ph-commons   文件: PDTFormatPatterns.java
@Nonnull
public static String getPatternTime (@Nonnull final FormatStyle eStyle, @Nonnull final Locale aDisplayLocale)
{
  return DateTimeFormatterBuilder.getLocalizedDateTimePattern (null, eStyle, IsoChronology.INSTANCE, aDisplayLocale);
}