return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault())); } catch (final DateTimeParseException e) {
/** * Returns a {@link java.time.Period} between the first day of this year (inclusive) and the first day of the * provided {@link java.time.Year} (exclusive). * * @param self a Year * @param year another Year * @return a Period between the Years * @since 2.5.0 */ public static Period rightShift(final Year self, Year year) { return Period.between(self.atDay(1), year.atDay(1)); }
/** * Combines this day-of-year with a year to create a {@code LocalDate}. * <p> * This returns a {@code LocalDate} formed from this day and the specified year. * <p> * This method can be used as part of a chain to produce a date: * <pre> * LocalDate date = day.atYear(year); * </pre> * <p> * The day-of-year value 366 is only valid in a leap year. * * @param year the year to use, not null * @return the local date formed from this day and the specified year, not null * @throws DateTimeException if the year is invalid or this is day 366 and the year is not a leap year */ public LocalDate atYear(Year year) { Objects.requireNonNull(year, "year"); return year.atDay(day); }
public static void getLocalDate(int year, int atDay) { LocalDate date = Year.of(year).atDay(atDay); // System.out.println(date); }
public static LocalDate randomDateIn(int year) { Year y = Year.of(year); return y.atDay(1+new Random().nextInt(y.length())); } System.out.println(randomDateIn(2014));
@Override public Instant get() { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); Year year = Year.parse(input, formatter); return year.atDay(1).atStartOfDay(timeZone.toZoneId()).toInstant(); } };
temporalAccessor = ((Year) temporalAccessor).atDay(1); } else if (temporalAccessor instanceof YearMonth) { temporalAccessor = ((YearMonth) temporalAccessor).atDay(1);
return ZonedDateTime.of(LocalDate.now(), localTime, defaultZoneId); } else if (target instanceof Year) { LocalDate localDate = ((Year) target).atDay(1); return ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, defaultZoneId); } else if (target instanceof YearMonth) {
/** * Gets a window of time on this calendar defined by the specified period. The window of time * will include only the events in this calendar that occur in the specified period. * @param year the year during which the events in this calendar occur. * @return the window of time including the events in this calendar occurring in the given period. */ public CalendarTimeWindow in(final Year year) { return between(year.atDay(1), year.atMonth(DECEMBER).atEndOfMonth()); }
public static Certificate newCert(String parentCertFile, String keyFile, String host) { try { Date before = Date.from(Instant.now()); Date after = Date.from(Year.now().plus(3, ChronoUnit.YEARS).atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); X509CertificateHolder parent = readPemFromFile(parentCertFile); PEMKeyPair pemKeyPair = readPemFromFile(keyFile); KeyPair keyPair = new JcaPEMKeyConverter() .setProvider(PROVIDER) .getKeyPair(pemKeyPair); X509v3CertificateBuilder x509 = new JcaX509v3CertificateBuilder( parent.getSubject(), new BigInteger(64, new SecureRandom()), before, after, new X500Name("CN=" + host), keyPair.getPublic()); ContentSigner signer = new JcaContentSignerBuilder("SHA256WithRSAEncryption") .build(keyPair.getPrivate()); JcaX509CertificateConverter x509CertificateConverter = new JcaX509CertificateConverter() .setProvider(PROVIDER); return new Certificate( keyPair, x509CertificateConverter.getCertificate(x509.build(signer)), x509CertificateConverter.getCertificate(parent)); } catch (Exception e) { throw new IllegalStateException(e); } }
temporalAccessor = ((YearMonth) temporalAccessor).atDay(1).plusMonths(1L); } else if (temporalAccessor instanceof Year) { temporalAccessor = ((Year) temporalAccessor).atDay(1).plusYears(1L);
ldt = YearMonth.from(ta).atDay(1); } else if (ta.isSupported(ChronoField.YEAR)) { ldt = Year.from(ta).atDay(1);
return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault())); } catch (final DateTimeParseException e) {
return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault())); } catch (final DateTimeParseException e) {
return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault())); } catch (final DateTimeParseException e) {