org.joda.time.LocalDate.withMonthOfYear()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(125)

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

LocalDate.withMonthOfYear介绍

[英]Returns a copy of this date with the month of year field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of month of year changed.
[中]

代码示例

代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics

/**
 * Adjust the input date to the first month of the year.
 *
 * @param date the input date
 * @return new date
 */
protected final LocalDate firstMonth(final LocalDate date) {
  return date.withMonthOfYear(1);
}

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

List<LocalDate> holidays = new ArrayList<LocalDate>();
LocalDate today = LocalDate.now();
holidays.add(today.withMonthOfYear(1).withDayOfMonth(1));
holidays.add(today.withMonthOfYear(1).withDayOfMonth(18));

代码示例来源:origin: fluxtream/fluxtream-app

public void setMonth(final int year, final int month) {
  timeUnit = timeUnit.MONTH;
  fromDate = new LocalDate(year, 1, 1).withMonthOfYear(month);
}

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

LocalDate localDate = new LocalDate( 2014 , 12 , 31 ); // December.
LocalDate localDate_Feb = localDate.withMonthOfYear( 2 ); // February.

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

private void trimMonth() {
  if (localDate == null) {
    return;
  }
  if (localDate.getMonthOfYear() != NULL_REPLACEMENT) {
    localDate = localDate.withMonthOfYear(NULL_REPLACEMENT);
  }
}

代码示例来源:origin: net.objectlab.kit/datecalc-joda

public static LocalDate getLocalDate(final double date, final boolean use1904windowing) {
  final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing);
  if (c == null) {
    return null;
  }
  return new LocalDate().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH));
}

代码示例来源:origin: Appendium/objectlabkit

public static LocalDate getLocalDate(final double date, final boolean use1904windowing) {
  final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing);
  if (c == null) {
    return null;
  }
  return new LocalDate().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH));
}

代码示例来源:origin: org.motechproject/motech-platform-commons-date

public static LocalDate newDate(int year, int month, int day) {
  return new LocalDate(DateTimeSourceUtil.timeZone())
      .withYear(year)
      .withMonthOfYear(month)
      .withDayOfMonth(day);
}

代码示例来源:origin: fluxtream/fluxtream-app

public static LocalDate getBeginningOfMonth(final int year, final int month) {
  return (new LocalDate())
      .withWeekyear(year)
      .withMonthOfYear(month).dayOfMonth().withMinimumValue();
}

代码示例来源:origin: fluxtream/fluxtream-app

public static LocalDate getEndOfMonth(final int year, final int month) {
  return (new LocalDate())
      .withWeekyear(year)
      .withMonthOfYear(month).dayOfMonth().withMaximumValue();
}

代码示例来源:origin: com.cronutils/htime

@VisibleForTesting
Map<String, String> initMonths(Locale locale) {
  String fullMonth =
      String.format("%s%s%s%s",
          constants.monthOfYear(), constants.monthOfYear(),
          constants.monthOfYear(), constants.monthOfYear()
      );
  String shortMonth = String.format("%s%s%s", constants.monthOfYear(),
      constants.monthOfYear(), constants.monthOfYear());
  LocalDate date = new LocalDate();
  Map<String, String> mapping = Maps.newHashMap();
  for (int j = 1; j < 13; j++) {
    String moy = date.withMonthOfYear(j).monthOfYear().getAsText(locale).toLowerCase();
    mapping.put(moy, fullMonth);
    mapping.put(moy.substring(0, 3), shortMonth);
  }
  return mapping;
}

代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics

/**
   * Adjust by the gap between children and to beginning of month.
   *
   * @param date the input date
   * @return the adjusted date
   */
  private LocalDate childAdjustment(final LocalDate date) {
    if (date == null) {
      return date;
    }
    return date.plusYears(typicals.gapBetweenChildren())
        .withMonthOfYear(1).withDayOfMonth(1);
  }
}

代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics

/**
 * Apply a standard adjustment from an ancestor's marriage date to a
 * person's birth date.
 *
 * @param date the ancestor's marriage date
 * @return the adjusted date
 */
private LocalDate ancestorAdjustment(final LocalDate date) {
  if (date == null) {
    return null;
  }
  return date.plusYears(typicals.ageAtMarriage()
      + typicals.gapBetweenChildren())
      .withMonthOfYear(1).withDayOfMonth(1);
}

相关文章