java.time.Year.atDay()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中java.time.Year.atDay()方法的一些代码示例,展示了Year.atDay()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Year.atDay()方法的具体详情如下:
包路径:java.time.Year
类名称:Year
方法名:atDay

Year.atDay介绍

[英]Combines this year with a day-of-year to create a LocalDate.

This returns a LocalDate formed from this year and the specified day-of-year.

The day-of-year value 366 is only valid in a leap year.
[中]将今年与一年中的某一天合并以创建LocalDate。
这将返回从今年到一年中指定日期形成的LocalDate。
日期值366仅在闰年有效。

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {

代码示例来源:origin: org.codehaus.groovy/groovy-datetime

/**
 * 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));
}

代码示例来源:origin: org.threeten/threeten-extra

/**
 * 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);
}

代码示例来源:origin: mars-sim/mars-sim

public static void getLocalDate(int year, int atDay) {
     LocalDate date = Year.of(year).atDay(atDay);
//          System.out.println(date);  
  }

代码示例来源:origin: stackoverflow.com

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));

代码示例来源:origin: no.ssb.vtl/java-vtl-model

@Override
  public Instant get() {
    DateTimeFormatter formatter =
        DateTimeFormatter.ofPattern("yyyy");
    Year year = Year.parse(input, formatter);
    return year.atDay(1).atStartOfDay(timeZone.toZoneId()).toInstant();
  }
};

代码示例来源:origin: edu.byu.hbll/time

temporalAccessor = ((Year) temporalAccessor).atDay(1);
} else if (temporalAccessor instanceof YearMonth) {
 temporalAccessor = ((YearMonth) temporalAccessor).atDay(1);

代码示例来源:origin: thymeleaf/thymeleaf-extras-java8time

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) {

代码示例来源:origin: Silverpeas/Silverpeas-Core

/**
 * 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());
}

代码示例来源:origin: chhsiao90/nitmproxy

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);
  }
}

代码示例来源:origin: edu.byu.hbll/time

temporalAccessor = ((YearMonth) temporalAccessor).atDay(1).plusMonths(1L);
} else if (temporalAccessor instanceof Year) {
 temporalAccessor = ((Year) temporalAccessor).atDay(1).plusYears(1L);

代码示例来源:origin: crawler-commons/crawler-commons

ldt =  YearMonth.from(ta).atDay(1);
} else if (ta.isSupported(ChronoField.YEAR)) {
  ldt = Year.from(ta).atDay(1);

代码示例来源:origin: x-stream/xstream

return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8

return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {

代码示例来源:origin: apache/servicemix-bundles

return GregorianCalendar.from(y.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {

相关文章