Java Code Examples for java.time.chrono.ThaiBuddhistDate#get()
The following examples show how to use
java.time.chrono.ThaiBuddhistDate#get() .
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: TestReducedParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 2
Source File: TestReducedParser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 3
Source File: TestReducedParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 4
Source File: TestReducedParser.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 5
Source File: TestReducedParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 6
Source File: TestReducedParser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 7
Source File: TestReducedParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 8
Source File: TestReducedParser.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 9
Source File: TestReducedParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 10
Source File: TestReducedParser.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 11
Source File: TestReducedParser.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
Example 12
Source File: TestExampleCode.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 13
Source File: TestExampleCode.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 14
Source File: TestExampleCode.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 15
Source File: TestExampleCode.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 16
Source File: TestExampleCode.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 17
Source File: TestExampleCode.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 18
Source File: TestExampleCode.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 19
Source File: TestExampleCode.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }
Example 20
Source File: TestExampleCode.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_calendarPackageExample() { // Enumerate the list of available calendars and print today for each Set<Chronology> chronos = Chronology.getAvailableChronologies(); for (Chronology chrono : chronos) { ChronoLocalDate date = chrono.dateNow(); System.out.printf(" %20s: %s%n", chrono.getId(), date.toString()); } // Print the Thai Buddhist date ThaiBuddhistDate now1 = ThaiBuddhistDate.now(); int day = now1.get(ChronoField.DAY_OF_MONTH); int dow = now1.get(ChronoField.DAY_OF_WEEK); int month = now1.get(ChronoField.MONTH_OF_YEAR); int year = now1.get(ChronoField.YEAR); System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year); // Print today's date and the last day of the year for the Thai Buddhist Calendar. ThaiBuddhistDate first = now1 .with(ChronoField.DAY_OF_MONTH, 1) .with(ChronoField.MONTH_OF_YEAR, 1); ThaiBuddhistDate last = first .plus(1, ChronoUnit.YEARS) .minus(1, ChronoUnit.DAYS); System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last); }