Java Code Examples for java.time.temporal.ChronoField#DAY_OF_MONTH
The following examples show how to use
java.time.temporal.ChronoField#DAY_OF_MONTH .
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 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
Source File: YearMonthTest.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void test_with_TemporalField_long_invalidField() { ChronoField[] invalidFields = new ChronoField[] { ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR, ChronoField.ALIGNED_WEEK_OF_MONTH, ChronoField.ALIGNED_WEEK_OF_YEAR, ChronoField.AMPM_OF_DAY, ChronoField.CLOCK_HOUR_OF_AMPM, ChronoField.CLOCK_HOUR_OF_DAY, ChronoField.DAY_OF_MONTH, ChronoField.DAY_OF_WEEK, ChronoField.DAY_OF_YEAR, ChronoField.EPOCH_DAY, ChronoField.HOUR_OF_AMPM, ChronoField.HOUR_OF_DAY, ChronoField.INSTANT_SECONDS, ChronoField.MICRO_OF_DAY, ChronoField.MICRO_OF_SECOND, ChronoField.MILLI_OF_DAY, ChronoField.MILLI_OF_SECOND, ChronoField.MINUTE_OF_DAY, ChronoField.MINUTE_OF_HOUR, ChronoField.NANO_OF_DAY, ChronoField.NANO_OF_SECOND, ChronoField.OFFSET_SECONDS, ChronoField.SECOND_OF_DAY, ChronoField.SECOND_OF_MINUTE, }; YearMonth ym = YearMonth.of(2000, Month.JANUARY); for (ChronoField invalidField : invalidFields) { // Get a valid value to ensure we fail to due invalid field, not due to invalid value. long value = invalidField.range().getMinimum(); try { ym.with(invalidField, value); fail("TemporalField.with() should not accept " + invalidField); } catch (UnsupportedTemporalTypeException expected) { } } }
Example 14
Source File: ZonedDateTimeMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 3 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<ZonedDateTime> isFirstDayOfMonth() { return new IsMinimum<ZonedDateTime>(ChronoField.DAY_OF_MONTH, t -> t, new DatePartFormatter(), () -> "the date is the first day of the month"); }
Example 15
Source File: ZonedDateTimeMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 3 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<ZonedDateTime> isLastDayOfMonth() { return new IsMaximum<ZonedDateTime>(ChronoField.DAY_OF_MONTH, t -> t, new DatePartFormatter(), () -> "the date is the last day of the month"); }
Example 16
Source File: LocalDateTimeMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 2 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<LocalDateTime> isLastDayOfMonth() { return new IsMaximum<LocalDateTime>(ChronoField.DAY_OF_MONTH, t -> t, new DatePartFormatter(), () -> "the date is the last day of the month"); }
Example 17
Source File: DateMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 2 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<Date> isLastDayOfMonth() { return new IsMaximum<Date>(ChronoField.DAY_OF_MONTH, DateMatchers::dateToZoneDateTime, new DatePartFormatter(), () -> "the date is the last day of the month"); }
Example 18
Source File: LocalDateMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 2 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<LocalDate> isFirstDayOfMonth() { return new IsMinimum<LocalDate>(ChronoField.DAY_OF_MONTH, t -> t, new DatePartFormatter(), () -> "the date is the first day of the month"); }
Example 19
Source File: LocalDateMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 2 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<LocalDate> isLastDayOfMonth() { return new IsMaximum<LocalDate>(ChronoField.DAY_OF_MONTH, t -> t, new DatePartFormatter(), () -> "the date is the last day of the month"); }
Example 20
Source File: DateMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 2 votes |
/** * Creates a matcher that matches when the examined date is on the first day of the month * <p/> * For example: * * <pre> * assertThat(myDate, isFirstDayOfMonth()); * </pre> */ public static Matcher<Date> isFirstDayOfMonth() { return new IsMinimum<Date>(ChronoField.DAY_OF_MONTH, DateMatchers::dateToZoneDateTime, new DatePartFormatter(), () -> "the date is the first day of the month"); }