當前位置: 首頁>>代碼示例>>Java>>正文


Java TextStyle.NARROW屬性代碼示例

本文整理匯總了Java中java.time.format.TextStyle.NARROW屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextStyle.NARROW屬性的具體用法?Java TextStyle.NARROW怎麽用?Java TextStyle.NARROW使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.time.format.TextStyle的用法示例。


在下文中一共展示了TextStyle.NARROW屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDisplayName

/**
 * {@inheritDoc}
 *
 * @param style {@inheritDoc}
 * @param locale {@inheritDoc}
 */
@Override
public String getDisplayName(TextStyle style, Locale locale) {
    // If this JapaneseEra is a supplemental one, obtain the name from
    // the era definition.
    if (getValue() > N_ERA_CONSTANTS - ERA_OFFSET) {
        Objects.requireNonNull(locale, "locale");
        return style.asNormal() == TextStyle.NARROW ? getAbbreviation() : getName();
    }

    return new DateTimeFormatterBuilder()
        .appendText(ERA, style)
        .toFormatter(locale)
        .withChronology(JapaneseChronology.INSTANCE)
        .format(this == MEIJI ? MEIJI_6_ISODATE : since);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:JapaneseEra.java

示例2: provider_japaneseEra

@DataProvider(name="print_JapaneseChronology")
Object[][] provider_japaneseEra() {
   return new Object[][] {
        {ERA,           TextStyle.FULL, 2, "Heisei"}, // Note: CLDR doesn't define "wide" Japanese era names.
        {ERA,           TextStyle.SHORT, 2, "Heisei"},
        {ERA,           TextStyle.NARROW, 2, "H"},
   };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:TestTextPrinter.java

示例3: provider_text

@DataProvider(name="parseText")
Object[][] provider_text() {
    return new Object[][] {
        {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"},
        {DAY_OF_WEEK, TextStyle.FULL, 2, "Tuesday"},
        {DAY_OF_WEEK, TextStyle.FULL, 3, "Wednesday"},
        {DAY_OF_WEEK, TextStyle.FULL, 4, "Thursday"},
        {DAY_OF_WEEK, TextStyle.FULL, 5, "Friday"},
        {DAY_OF_WEEK, TextStyle.FULL, 6, "Saturday"},
        {DAY_OF_WEEK, TextStyle.FULL, 7, "Sunday"},

        {DAY_OF_WEEK, TextStyle.SHORT, 1, "Mon"},
        {DAY_OF_WEEK, TextStyle.SHORT, 2, "Tue"},
        {DAY_OF_WEEK, TextStyle.SHORT, 3, "Wed"},
        {DAY_OF_WEEK, TextStyle.SHORT, 4, "Thu"},
        {DAY_OF_WEEK, TextStyle.SHORT, 5, "Fri"},
        {DAY_OF_WEEK, TextStyle.SHORT, 6, "Sat"},
        {DAY_OF_WEEK, TextStyle.SHORT, 7, "Sun"},

        {MONTH_OF_YEAR, TextStyle.FULL, 1, "January"},
        {MONTH_OF_YEAR, TextStyle.FULL, 12, "December"},

        {MONTH_OF_YEAR, TextStyle.SHORT, 1, "Jan"},
        {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"},

        {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"},
        {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"},
        {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"},
        {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"},

        {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"},
        {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"},
        {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"},
        {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"},

        {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"},
        {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"},
        {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"},
        {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"},
   };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:41,代碼來源:TestTextParser.java


注:本文中的java.time.format.TextStyle.NARROW屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。