Java Code Examples for java.time.temporal.ChronoField#DAY_OF_YEAR
The following examples show how to use
java.time.temporal.ChronoField#DAY_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 |
private static ChronoField getPrecision(String text) { if (text.endsWith("T")) { return ChronoField.DAY_OF_YEAR; } String time = text.contains("T") ? text.substring(text.indexOf("T") + 1) : text; if (time.contains("+") || time.contains("-") || time.endsWith("Z")) { return ChronoField.OFFSET_SECONDS; } int count = count(time, ':'); switch (count) { case 0: return ChronoField.HOUR_OF_DAY; case 1: return ChronoField.MINUTE_OF_HOUR; case 2: return ChronoField.MICRO_OF_SECOND; } throw new IllegalArgumentException(text); }
Example 2
Source File: BattleLogs.java From logbook-kai with MIT License | 4 votes |
@Override public boolean accept(ZonedDateTime target, ZonedDateTime now) { TemporalField field = ChronoField.DAY_OF_YEAR; return now.get(field) == target.get(field); }
Example 3
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) { } } }