public int getMonth() { return localDate.getMonthValue(); }
protected void _serializeAsArrayContents(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber(value.getYear()); g.writeNumber(value.getMonthValue()); g.writeNumber(value.getDayOfMonth()); }
private void writeLog(String msg) { LocalDate today = LocalDate.now(); int year = today.getYear(); int month = today.getMonthValue(); int day = today.getDayOfMonth(); String dir = appConfiguration.getMsgLoggerPath() + appConfiguration.getUserName() + "/"; String fileName = dir + year + month + day + ".log"; Path file = Paths.get(fileName); boolean exists = Files.exists(Paths.get(dir), LinkOption.NOFOLLOW_LINKS); try { if (!exists) { Files.createDirectories(Paths.get(dir)); } List<String> lines = Arrays.asList(msg); Files.write(file, lines, Charset.forName("UTF-8"), StandardOpenOption.CREATE, StandardOpenOption.APPEND); } catch (IOException e) { LOGGER.info("IOException", e); } }
private static void appendDate(StringBuilder sb, LocalDate localDate) { int year = Math.abs(localDate.getYear()); // year is negative for BC dates int month = localDate.getMonthValue(); int day = localDate.getDayOfMonth(); appendDate(sb, year, month, day); }
int gtfsDate = date.getYear() * 10000 + date.getMonthValue() * 100 + date.getDayOfMonth(); boolean withinValidityRange = calendar.end_date >= gtfsDate && calendar.start_date <= gtfsDate;
protected void _serializeAsArrayContents(LocalDate value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber(value.getYear()); g.writeNumber(value.getMonthValue()); g.writeNumber(value.getDayOfMonth()); }
public static int pack(LocalDate date) { if (date == null) { return DateColumnType.missingValueIndicator(); } return pack( (short) date.getYear(), (byte) date.getMonthValue(), (byte) date.getDayOfMonth()); }
static TimestampParserLegacy of(final String formatString, final ZoneId defaultZoneId, final org.joda.time.DateTimeZone defaultJodaDateTimeZone, final String defaultDateString) { final LocalDate defaultDate = parseDateForDefault(defaultDateString); return of(formatString, defaultZoneId, defaultJodaDateTimeZone, defaultDate.getYear(), defaultDate.getMonthValue(), defaultDate.getDayOfMonth()); }
static String getSeason(LocalDate date) { String season = ""; int month = date.getMonthValue(); int day = date.getDayOfMonth(); if ( month == 1 || month == 2 || ( month == 3 && day <= 15 ) || ( month == 12 && day >= 16 )) season = "WINTER"; else if ( month == 4 || month == 5 || ( month == 3 && day >= 16 ) || ( month == 6 && day <= 15 )) season = "SPRING"; else if ( month == 7 || month == 8 || ( month == 6 && day >= 16 ) || ( month == 9 && day <= 15 )) season = "SUMMER"; else if ( month == 10|| month == 11 || ( month == 9 && day >= 16 ) || ( month == 12 && day <= 15 )) season = "FALL"; return season; }
@RequestMapping("/bind") public String handle(DateClass data, BindingResult result) { if (result.hasErrors()) { return result.getFieldError().toString(); } assertNotNull(data); assertNotNull(data.date); assertEquals(2010, data.date.getYear()); assertEquals(1, data.date.getMonthValue()); assertEquals(1, data.date.getDayOfMonth()); return result.getFieldValue("date").toString(); } }
@SuppressWarnings("deprecation") @Test public void shouldReturnLocalDateTimeInstanceWhenConvertingSqlDateToLocalDateTime() { LocalDate now = LocalDate.now(); java.sql.Date date = new java.sql.Date(now.getYear()-1900,now.getMonthValue()-1,now.getDayOfMonth()); assertThat(Conversions.toLocalDateTime(date)).isEqualTo(LocalDateTime.of(now, LocalTime.MIDNIGHT)); }
@SuppressWarnings("deprecation") @Test public void shouldReturnLocalDateInstanceWhenConvertingSqlDateToLocalDate() { LocalDate now = LocalDate.now(); java.sql.Date date = new java.sql.Date(now.getYear()-1900,now.getMonthValue()-1,now.getDayOfMonth()); assertThat(Conversions.toLocalDate(date)).isEqualTo(now); }
@SuppressWarnings("deprecation") @Test public void shouldReturnLocalDateInstanceWhenConvertingUtilDateToLocalDate() { LocalDate now = LocalDate.now(); java.util.Date date = new java.util.Date(now.getYear()-1900,now.getMonthValue()-1,now.getDayOfMonth()); assertThat(Conversions.toLocalDate(date)).isEqualTo(now); }
@Override protected ByteBuf writeValue(final LocalDate value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException { return allocator.buffer(6).writeInt(value.getYear()).writeByte(value.getMonthValue()).writeByte(value.getDayOfMonth()); } }
Date date = new Date(); LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); int year = localDate.getYear(); int month = localDate.getMonthValue(); int day = localDate.getDayOfMonth();
public static org.joda.time.LocalDate toJodaLocalDate(final LocalDate localDate) { return new org.joda.time.LocalDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth()); }
private MonthDay convertFromDate(Date ts) { LocalDate localDate = ts.toLocalDate(); return MonthDay.of(localDate.getMonthValue(), localDate.getDayOfMonth()); }
public static org.joda.time.DateTime toJodaDateTime(final LocalDate localDate, final LocalTime localTime) { return new DateTime(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth(), localTime.getHour(), localTime.getMinute(), localTime.getSecond()); }
public static org.joda.time.LocalDateTime toJodaLocalDateTime(final LocalDate localDate, final LocalTime localTime) { return new LocalDateTime(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth(), localTime.getHour(), localTime.getMinute(), localTime.getSecond()); } }
@Override public MonthDay generate(SourceOfRandomness random, GenerationStatus status) { /* Project the MonthDay to a LocalDate for easy long-based generation. Any leap year will do here. */ long minEpochDay = min.atYear(2000).toEpochDay(); long maxEpochDay = max.atYear(2000).toEpochDay(); LocalDate date = LocalDate.ofEpochDay(random.nextLong(minEpochDay, maxEpochDay)); return MonthDay.of(date.getMonthValue(), date.getDayOfMonth()); } }