Java Code Examples for java.time.chrono.IsoChronology#INSTANCE
The following examples show how to use
java.time.chrono.IsoChronology#INSTANCE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTimeFormatterBuilder.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public boolean format(DateTimePrintContext context, StringBuilder buf) { Long value = context.getValue(field); if (value == null) { return false; } String text; Chronology chrono = context.getTemporal().query(TemporalQueries.chronology()); if (chrono == null || chrono == IsoChronology.INSTANCE) { text = provider.getText(field, value, textStyle, context.getLocale()); } else { text = provider.getText(chrono, field, value, textStyle, context.getLocale()); } if (text == null) { return numberPrinterParser().format(context, buf); } buf.append(text); return true; }
Example 2
Source File: DateTimeFormatterBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean format(DateTimePrintContext context, StringBuilder buf) { Long value = context.getValue(field); if (value == null) { return false; } String text; Chronology chrono = context.getTemporal().query(TemporalQueries.chronology()); if (chrono == null || chrono == IsoChronology.INSTANCE) { text = provider.getText(field, value, textStyle, context.getLocale()); } else { text = provider.getText(chrono, field, value, textStyle, context.getLocale()); } if (text == null) { return numberPrinterParser().format(context, buf); } buf.append(text); return true; }
Example 3
Source File: DateTimeTextProvider.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Gets the text for the specified chrono, field, locale and style * for the purpose of formatting. * <p> * The text associated with the value is returned. * The null return value should be used if there is no applicable text, or * if the text would be a numeric representation of the value. * * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param value the field value to get text for, not null * @param style the style to get text for, not null * @param locale the locale to get text for, not null * @return the text for the field value, null if no text found */ public String getText(Chronology chrono, TemporalField field, long value, TextStyle style, Locale locale) { if (chrono == IsoChronology.INSTANCE || !(field instanceof ChronoField)) { return getText(field, value, style, locale); } int fieldIndex; int fieldValue; if (field == ERA) { fieldIndex = Calendar.ERA; if (chrono == JapaneseChronology.INSTANCE) { if (value == -999) { fieldValue = 0; } else { fieldValue = (int) value + 2; } } else { fieldValue = (int) value; } } else if (field == MONTH_OF_YEAR) { fieldIndex = Calendar.MONTH; fieldValue = (int) value - 1; } else if (field == DAY_OF_WEEK) { fieldIndex = Calendar.DAY_OF_WEEK; fieldValue = (int) value + 1; if (fieldValue > 7) { fieldValue = Calendar.SUNDAY; } } else if (field == AMPM_OF_DAY) { fieldIndex = Calendar.AM_PM; fieldValue = (int) value; } else { return null; } return CalendarDataUtility.retrieveJavaTimeFieldValueName( chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); }
Example 4
Source File: TCKChronoLocalDateTimeSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example 5
Source File: TestIsoChronology.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_chrono_byName() { Chronology c = IsoChronology.INSTANCE; Chronology test = Chronology.of("ISO"); Assert.assertNotNull(test, "The ISO calendar could not be found byName"); Assert.assertEquals(test.getId(), "ISO", "ID mismatch"); Assert.assertEquals(test.getCalendarType(), "iso8601", "Type mismatch"); Assert.assertEquals(test, c); }
Example 6
Source File: TestIsoChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_chrono_byName() { Chronology c = IsoChronology.INSTANCE; Chronology test = Chronology.of("ISO"); Assert.assertNotNull(test, "The ISO calendar could not be found byName"); Assert.assertEquals(test.getId(), "ISO", "ID mismatch"); Assert.assertEquals(test.getCalendarType(), "iso8601", "Type mismatch"); Assert.assertEquals(test, c); }
Example 7
Source File: TCKOffsetDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="query") Object[][] data_query() { return new Object[][] { {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.chronology(), IsoChronology.INSTANCE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zoneId(), null}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.precision(), ChronoUnit.NANOS}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zone(), OFFSET_PONE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.offset(), OFFSET_PONE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localDate(), LocalDate.of(2008, 6, 30)}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localTime(), LocalTime.of(11, 30, 59, 500)}, }; }
Example 8
Source File: TCKOffsetDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="query") Object[][] data_query() { return new Object[][] { {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.chronology(), IsoChronology.INSTANCE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zoneId(), null}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.precision(), ChronoUnit.NANOS}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zone(), OFFSET_PONE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.offset(), OFFSET_PONE}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localDate(), LocalDate.of(2008, 6, 30)}, {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localTime(), LocalTime.of(11, 30, 59, 500)}, }; }
Example 9
Source File: TCKChronoPeriod.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example 10
Source File: TCKChronoZonedDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}, }; }
Example 11
Source File: DateTimeTextProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Gets the text for the specified chrono, field, locale and style * for the purpose of formatting. * <p> * The text associated with the value is returned. * The null return value should be used if there is no applicable text, or * if the text would be a numeric representation of the value. * * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param value the field value to get text for, not null * @param style the style to get text for, not null * @param locale the locale to get text for, not null * @return the text for the field value, null if no text found */ public String getText(Chronology chrono, TemporalField field, long value, TextStyle style, Locale locale) { if (chrono == IsoChronology.INSTANCE || !(field instanceof ChronoField)) { return getText(field, value, style, locale); } int fieldIndex; int fieldValue; if (field == ERA) { fieldIndex = Calendar.ERA; if (chrono == JapaneseChronology.INSTANCE) { if (value == -999) { fieldValue = 0; } else { fieldValue = (int) value + 2; } } else { fieldValue = (int) value; } } else if (field == MONTH_OF_YEAR) { fieldIndex = Calendar.MONTH; fieldValue = (int) value - 1; } else if (field == DAY_OF_WEEK) { fieldIndex = Calendar.DAY_OF_WEEK; fieldValue = (int) value + 1; if (fieldValue > 7) { fieldValue = Calendar.SUNDAY; } } else if (field == AMPM_OF_DAY) { fieldIndex = Calendar.AM_PM; fieldValue = (int) value; } else { return null; } return CalendarDataUtility.retrieveJavaTimeFieldValueName( chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); }
Example 12
Source File: DateTimeFormatterBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public int parse(DateTimeParseContext context, CharSequence parseText, int position) { int length = parseText.length(); if (position < 0 || position > length) { throw new IndexOutOfBoundsException(); } TextStyle style = (context.isStrict() ? textStyle : null); Chronology chrono = context.getEffectiveChronology(); Iterator<Entry<String, Long>> it; if (chrono == null || chrono == IsoChronology.INSTANCE) { it = provider.getTextIterator(field, style, context.getLocale()); } else { it = provider.getTextIterator(chrono, field, style, context.getLocale()); } if (it != null) { while (it.hasNext()) { Entry<String, Long> entry = it.next(); String itText = entry.getKey(); if (context.subSequenceEquals(itText, 0, parseText, position, itText.length())) { return context.setParsedField(field, entry.getValue(), position, position + itText.length()); } } if (context.isStrict()) { return ~position; } } return numberPrinterParser().parse(context, parseText, position); }
Example 13
Source File: TCKMonthDay.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="query") Object[][] data_query() { return new Object[][] { {TEST_07_15, TemporalQueries.chronology(), IsoChronology.INSTANCE}, {TEST_07_15, TemporalQueries.zoneId(), null}, {TEST_07_15, TemporalQueries.precision(), null}, {TEST_07_15, TemporalQueries.zone(), null}, {TEST_07_15, TemporalQueries.offset(), null}, {TEST_07_15, TemporalQueries.localDate(), null}, {TEST_07_15, TemporalQueries.localTime(), null}, }; }
Example 14
Source File: TCKChronology.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendarsystemtype") Object[][] data_CalendarType() { return new Object[][] { {HijrahChronology.INSTANCE, "islamic-umalqura"}, {IsoChronology.INSTANCE, "iso8601"}, {JapaneseChronology.INSTANCE, "japanese"}, {MinguoChronology.INSTANCE, "roc"}, {ThaiBuddhistChronology.INSTANCE, "buddhist"}, }; }
Example 15
Source File: TCKChronoLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Chronology[][] data_of_calendars() { return new Chronology[][]{ {HijrahChronology.INSTANCE}, {IsoChronology.INSTANCE}, {JapaneseChronology.INSTANCE}, {MinguoChronology.INSTANCE}, {ThaiBuddhistChronology.INSTANCE}}; }
Example 16
Source File: TCKMonthDay.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="query") Object[][] data_query() { return new Object[][] { {TEST_07_15, TemporalQueries.chronology(), IsoChronology.INSTANCE}, {TEST_07_15, TemporalQueries.zoneId(), null}, {TEST_07_15, TemporalQueries.precision(), null}, {TEST_07_15, TemporalQueries.zone(), null}, {TEST_07_15, TemporalQueries.offset(), null}, {TEST_07_15, TemporalQueries.localDate(), null}, {TEST_07_15, TemporalQueries.localTime(), null}, }; }
Example 17
Source File: TestDateTimeFormatterBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@DataProvider(name="localePatterns") Object[][] localizedDateTimePatterns() { return new Object[][] { {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy h:mm:ss a z"}, {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy h:mm:ss a z"}, {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy h:mm:ss a"}, {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "M/d/yy h:mm a"}, {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy"}, {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy"}, {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy"}, {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.US, "M/d/yy"}, {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"}, {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"}, {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a"}, {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "h:mm a"}, // French Locale and ISO Chronology {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy HH' h 'mm z"}, {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy HH:mm:ss z"}, {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy HH:mm:ss"}, {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy HH:mm"}, {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy"}, {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy"}, {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy"}, {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy"}, {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "HH' h 'mm z"}, {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss z"}, {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss"}, {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm"}, // Japanese Locale and JapaneseChronology {FormatStyle.FULL, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5' H'\u6642'mm'\u5206'ss'\u79d2' z"}, {FormatStyle.LONG, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss z"}, {FormatStyle.MEDIUM, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss"}, {FormatStyle.SHORT, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm"}, {FormatStyle.FULL, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5'"}, {FormatStyle.LONG, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"}, {FormatStyle.MEDIUM, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"}, {FormatStyle.SHORT, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"}, {null, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H'\u6642'mm'\u5206'ss'\u79d2' z"}, {null, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss z"}, {null, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss"}, {null, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm"}, // Chinese Local and Chronology {FormatStyle.FULL, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE ahh'\u65f6'mm'\u5206'ss'\u79d2' z"}, {FormatStyle.LONG, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5 ahh'\u65f6'mm'\u5206'ss'\u79d2'"}, {FormatStyle.MEDIUM, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d H:mm:ss"}, {FormatStyle.SHORT, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d ah:mm"}, {FormatStyle.FULL, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE"}, {FormatStyle.LONG, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5"}, {FormatStyle.MEDIUM, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"}, {FormatStyle.SHORT, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"}, {null, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2' z"}, {null, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2'"}, {null, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "H:mm:ss"}, {null, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "ah:mm"}, }; }
Example 18
Source File: LocalDate.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Gets the chronology of this date, which is the ISO calendar system. * <p> * The {@code Chronology} represents the calendar system in use. * The ISO-8601 calendar system is the modern civil calendar system used today * in most of the world. It is equivalent to the proleptic Gregorian calendar * system, in which today's rules for leap years are applied for all time. * * @return the ISO chronology, not null */ @Override public IsoChronology getChronology() { return IsoChronology.INSTANCE; }
Example 19
Source File: Period.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Gets the chronology of this period, which is the ISO calendar system. * <p> * The {@code Chronology} represents the calendar system in use. * The ISO-8601 calendar system is the modern civil calendar system used today * in most of the world. It is equivalent to the proleptic Gregorian calendar * system, in which today's rules for leap years are applied for all time. * * @return the ISO chronology, not null */ @Override public IsoChronology getChronology() { return IsoChronology.INSTANCE; }
Example 20
Source File: Period.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Gets the chronology of this period, which is the ISO calendar system. * <p> * The {@code Chronology} represents the calendar system in use. * The ISO-8601 calendar system is the modern civil calendar system used today * in most of the world. It is equivalent to the proleptic Gregorian calendar * system, in which today's rules for leap years are applied for all time. * * @return the ISO chronology, not null */ @Override public IsoChronology getChronology() { return IsoChronology.INSTANCE; }