Java Code Examples for java.time.temporal.ChronoField#MONTH_OF_YEAR
The following examples show how to use
java.time.temporal.ChronoField#MONTH_OF_YEAR .
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: FHIRPathUtil.java From FHIR with Apache License 2.0 | 6 votes |
public static ChronoField getPrecision(TemporalAccessor temporalAccessor, String text) { if (temporalAccessor instanceof Year) { return ChronoField.YEAR; } if (temporalAccessor instanceof YearMonth) { return ChronoField.MONTH_OF_YEAR; } if (temporalAccessor instanceof LocalDate) { return ChronoField.DAY_OF_MONTH; } if (temporalAccessor instanceof LocalDateTime || temporalAccessor instanceof ZonedDateTime || temporalAccessor instanceof LocalTime) { if (text != null) { return getPrecision(text); } return (temporalAccessor instanceof ZonedDateTime) ? ChronoField.OFFSET_SECONDS : ChronoField.MICRO_OF_SECOND; } throw new IllegalArgumentException(); }
Example 2
Source File: TestChronoField.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 3
Source File: YearMonthTest.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_with_TemporalField_long_invalidValue() { Object[][] invalidValues = new Object[][] { { ChronoField.YEAR_OF_ERA, 0 }, { ChronoField.YEAR_OF_ERA, Year.MAX_VALUE + 1 }, { ChronoField.YEAR, Year.MIN_VALUE - 1 }, { ChronoField.YEAR, Year.MAX_VALUE + 1 }, { ChronoField.ERA, -1 }, { ChronoField.ERA, 2 }, { ChronoField.MONTH_OF_YEAR, -1 }, { ChronoField.MONTH_OF_YEAR, 0 }, { ChronoField.MONTH_OF_YEAR, 13 }, { ChronoField.PROLEPTIC_MONTH, Year.MAX_VALUE * 12L + 12 }, { ChronoField.PROLEPTIC_MONTH, Year.MIN_VALUE * 12L - 1 }, }; YearMonth ym = YearMonth.of(2000, Month.JANUARY); for (Object[] values : invalidValues) { ChronoField field = (ChronoField) values[0]; long value = ((Number) values[1]).longValue(); try { ym.with(field, value); fail("ym.with(" + field + ", " + value + ") should have failed."); } catch (DateTimeException expected) { } } }
Example 4
Source File: TestChronoField.java From j2objc with Apache License 2.0 | 5 votes |
Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 5
Source File: TestChronoField.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 6
Source File: TestChronoField.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 7
Source File: DateSlot.java From Mutters with Apache License 2.0 | 5 votes |
private LocalDate tryParse(String token, int currentYear, DateTimeFormatter fmt) { try { // workaround for migrating jodatime 'withDefault...' see: // https://stackoverflow.com/a/49815584/6122976 // init the defaults LocalDate defaults = LocalDate.of(currentYear, Month.JANUARY, 1); // parse string TemporalAccessor parsed = fmt.parse(token); // override defaults with parsed values ChronoField[] fieldsToOverride = { ChronoField.YEAR, ChronoField.MONTH_OF_YEAR, ChronoField.DAY_OF_MONTH }; for (TemporalField fieldToOverride : fieldsToOverride) { if (parsed.isSupported(fieldToOverride)) { defaults = defaults.with(fieldToOverride, parsed.getLong(fieldToOverride)); } } return defaults; } catch (DateTimeParseException e) { return null; } }
Example 8
Source File: TestChronoField.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 9
Source File: TestChronoField.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 10
Source File: TestChronoField.java From hottub with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 11
Source File: TestChronoField.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 12
Source File: TestChronoField.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 13
Source File: TestChronoField.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 14
Source File: TestChronoField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 15
Source File: TestChronoField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 16
Source File: TestChronoField.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 17
Source File: TestChronoField.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, {ChronoField.YEAR}, {ChronoField.MONTH_OF_YEAR}, {ChronoField.DAY_OF_WEEK}, // {ChronoField.ALIGNED_WEEK_OF_YEAR}, {ChronoField.DAY_OF_MONTH}, {ChronoField.AMPM_OF_DAY}, {ChronoField.HOUR_OF_DAY}, {ChronoField.MINUTE_OF_HOUR}, {ChronoField.SECOND_OF_MINUTE}, }; }
Example 18
Source File: BattleLogs.java From logbook-kai with MIT License | 4 votes |
@Override public boolean accept(ZonedDateTime target, ZonedDateTime now) { TemporalField field = ChronoField.MONTH_OF_YEAR; return now.get(field) == target.get(field); }
Example 19
Source File: BattleLogs.java From logbook-kai with MIT License | 4 votes |
@Override public boolean accept(ZonedDateTime target, ZonedDateTime now) { TemporalField field = ChronoField.MONTH_OF_YEAR; return now.minusMonths(1).get(field) == target.get(field); }