gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-18 01:24:40 27 4
gpt4 key购买 nike

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

YearMonth.atDay介绍

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

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

The day-of-month value must be valid for the year-month.

This method can be used as part of a chain to produce a date:

LocalDate date = year.atMonth(month).atDay(day);

[中]将今年的月份与月份中的某一天合并以创建LocalDate。
这将返回从今年月份和指定的月份日期形成的LocalDate。
“月日”值必须对该年的月份有效。
此方法可作为链的一部分用于生成日期:

LocalDate date = year.atMonth(month).atDay(day);

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

private String formatMonth(YearMonth yearMonth) {
  try {
    Chronology chrono = getPrimaryChronology();
    ChronoLocalDate cDate = chrono.date(yearMonth.atDay(1));
    return monthFormatter.withLocale(getLocale()).withChronology(chrono).format(cDate);
  } catch (DateTimeException ex) {
    // Date is out of range.
    return "";
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

void updateWeekNumberDateCells() {
  if (datePicker.isShowWeekNumbers()) {
    final Locale locale = getLocale();
    LocalDate firstDayOfMonth = selectedYearMonth.get().atDay(1);
    for (int i = 0; i < 6; i++) {
      LocalDate date = firstDayOfMonth.plus(i, WEEKS);
      String weekNumber = weekNumberFormatter.withLocale(locale)
        .withDecimalStyle(DecimalStyle.of(locale))
        .format(date);
      weekNumberCells.get(i).setText(weekNumber);
    }
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

protected void updateMonthYearPane() {
  // update date labels
  YearMonth yearMonth = selectedYearMonth.get();
  LocalDate value = datePicker.getValue();
  value = value == null ? LocalDate.now() : value;
  selectedDateLabel.setText(DateTimeFormatter.ofPattern("EEE, MMM dd").format(value));
  selectedYearLabel.setText(formatYear(yearMonth));
  monthYearLabel.setText(formatMonth(yearMonth) + " " + formatYear(yearMonth));
  Chronology chrono = datePicker.getChronology();
  LocalDate firstDayOfMonth = yearMonth.atDay(1);
  backMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, -1, DAYS));
  forwardMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, +1, MONTHS));
}

代码示例来源:origin: jfoenixadmin/JFoenix

private String formatYear(YearMonth yearMonth) {
  try {
    Chronology chrono = getPrimaryChronology();
    ChronoLocalDate cDate = chrono.date(yearMonth.atDay(1));
    return yearFormatter.withLocale(getLocale())
      .withChronology(chrono)
      .withDecimalStyle(DecimalStyle.of(getLocale()))
      .format(cDate);
  } catch (DateTimeException ex) {
    // Date is out of range.
    return "";
  }
}

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

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

代码示例来源:origin: jfoenixadmin/JFoenix

int firstOfMonthIndex = selectedYearMonth.get().atDay(1).getDayOfWeek().getValue() - firstDayOfWeek;
firstOfMonthIndex += firstOfMonthIndex < 0 ? daysPerWeek : 0;
YearMonth currentYearMonth = selectedYearMonth.get();
    LocalDate date = currentYearMonth.atDay(dayIndex);
    dayCellDates[i] = date;

代码示例来源:origin: jfoenixadmin/JFoenix

DateCell dateCell = currentFocusedDayCell;
if (dateCell == null || !(dayCellDate(dateCell).getMonth() == yearMonth.getMonth())) {
  dateCell = findDayCellOfDate(yearMonth.atDay(1));

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

// From Date to YearMonth
YearMonth yearMonth =
    YearMonth.from(date.toInstant()
              .atZone(ZoneId.systemDefault())
              .toLocalDate());

// From YearMonth to Date
// The same as the OP:s answer
final Date convertedFromYearMonth = 
    Date.from(yearMonth.atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant());

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

/**
 * Returns a {@link java.time.LocalDate} of this year/month and the given day of the month.
 *
 * @param self       a YearMonth
 * @param dayOfMonth a day of the month
 * @return a LocalDate
 * @since 2.5.0
 */
public static LocalDate leftShift(final YearMonth self, int dayOfMonth) {
  return self.atDay(dayOfMonth);
}

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

/**
 * Returns a {@link java.time.Period} of time between the first day of this year/month (inclusive) and the
 * given {@link java.time.YearMonth} (exclusive).
 *
 * @param self  a YearMonth
 * @param other another YearMonth
 * @return a Period
 * @since 2.5.0
 */
public static Period rightShift(YearMonth self, YearMonth other) {
  return Period.between(self.atDay(1), other.atDay(1));
}

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

// Code for your method.
YearMonth yearMonth = year.atMonth ( month ); // Instantiate a YearMonth from a Year and a Month.
LocalDate localDate = yearMonth.atDay ( 1 ); // First day of month.
ZoneId zoneId = ZoneId.systemDefault (); // Or… ZoneId.of("America/Montreal");
ZonedDateTime zdt = localDate.atStartOfDay ( zoneId );
long millis = zdt.toInstant ().toEpochMilli ();

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public Date convert(YearMonth in, Context context) throws Exception {
    if (in == null) return null;
    return Date.from(in.atDay(1).atStartOfDay(zoneId).toInstant());
  }
}

代码示例来源:origin: org.simpleflatmapper/sfm-converter

@Override
  public Date convert(YearMonth in, Context context) throws Exception {
    if (in == null) return null;
    return Date.from(in.atDay(1).atStartOfDay(zoneId).toInstant());
  }
}

代码示例来源:origin: OpenGamma/Strata

@Override
 public LocalDate dateMatching(YearMonth yearMonth) {
  return nextOrSame(yearMonth.atDay(1));
 }
};

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

YearMonth yearMonthObject = YearMonth.of(year, month);
int daysOfCurrentMonth = yearMonthObject.lengthOfMonth();

ArrayList<LocalDate> dayes = new ArrayList<LocalDate>();
for(int i = 1; i <= daysOfCurrentMonth; i++){
  dayes.add(yearMonthObject.atDay(i));
}

dayes.forEach(value -> System.out.println(value.getDayOfMonth() + " " + value.getDayOfWeek()));

代码示例来源:origin: OpenGamma/Strata

@Override
 public LocalDate dateMatching(YearMonth yearMonth) {
  return nextOrSame(yearMonth.atDay(1));
 }
},

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

ZonedId zoneId = ZoneId.of( "America/Montreal" );
YearMonth yearMonthNow = YearMonth.now( zoneId );
YearMonth yearMonthPrevious = yearMonthNow.minusMonths( 1 );
LocalDate firstOfMonth = yearMonthPrevious.atDay( 1 );
LocalDate lastOfMonth = yearMonthPrevious.atEndOfMonth();

代码示例来源:origin: com.github.robozonky/robozonky-api

public static OffsetDateTime toOffsetDateTime(final String format, final String date) {
  switch (format) { // the only two formats, as confirmed via e-mail with Zonky employees
    case "yyyy-MM":
      return YearMonth.parse(date, YEAR_MONTH)
          .atDay(1)
          .atStartOfDay(Defaults.ZONE_ID).toOffsetDateTime();
    case "yyyy-MM-dd'T'HH:mm:ssZ":
      return OffsetDateTime.parse(date, DateTimeFormatter.ISO_DATE_TIME);
    default:
      throw new IllegalArgumentException("Unknown date format ID: " + format);
  }
}

代码示例来源:origin: kaif-open/kaif

/**
 * create monthly ranking now
 */
public static HonorRoll zero(UUID accountId, Zone zone, YearMonth yearMonth, String username) {
 return new HonorRoll(accountId, zone, yearMonth.atDay(1).toString(), username, 0, 0, 0);
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Test
public void testJavaYearMonth() throws Exception {
  java.time.YearMonth value = java.time.YearMonth.now();
  java.time.ZoneId zoneId = ZoneId.of("America/Los_Angeles");
  newFieldMapperAndMapToPS(new ConstantGetter<Object, java.time.YearMonth>(value),  java.time.YearMonth.class, new JavaZoneIdProperty(zoneId));
  newFieldMapperAndMapToPS(NullGetter.<Object,  java.time.YearMonth>getter(), java.time.YearMonth.class);
  verify(ps).setDate(1, new java.sql.Date(value.atDay(1).atStartOfDay(zoneId).toInstant().toEpochMilli()));
  verify(ps).setNull(2, Types.DATE);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com