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

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

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

LocalDate.getMonthOfYear介绍

[英]Get the month of year field value.
[中]获取“月份”字段值。

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code YearMonth} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static YearMonth parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new YearMonth(date.getYear(), date.getMonthOfYear());
}

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code MonthDay} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static MonthDay parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code YearMonth} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static YearMonth parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new YearMonth(date.getYear(), date.getMonthOfYear());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code MonthDay} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static MonthDay parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: joda-time/joda-time

/**
 * Returns a copy of this datetime with the specified date, retaining the time fields.
 * <p>
 * If the time is invalid on the new date due to the time-zone, the time will be adjusted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param date  the local date
 * @return a copy of this datetime with a different date
 * @throws IllegalArgumentException if the time-of-day is invalid for the date
 * @throws NullPointerException if the date is null
 */
public DateTime withDate(LocalDate date) {
  return withDate(
    date.getYear(), date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Returns a copy of this datetime with the specified date, retaining the time fields.
 * <p>
 * If the time is invalid on the new date due to the time-zone, the time will be adjusted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param date  the local date
 * @return a copy of this datetime with a different date
 * @throws IllegalArgumentException if the time-of-day is invalid for the date
 * @throws NullPointerException if the date is null
 */
public DateTime withDate(LocalDate date) {
  return withDate(
    date.getYear(), date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: joda-time/joda-time

new LocalDate(2001, month, day).plusDays(1));
advance = (day != -1 && dayOfWeek != 0);
month = date.getMonthOfYear();
day = date.getDayOfMonth();
if (dayOfWeek != 0) {

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this LocalDate to a full datetime at midnight using the
 * specified time zone.
 * <p>
 * This method will throw an exception if the time zone switches
 * to Daylight Savings Time at midnight and this LocalDate represents
 * that switchover date. The problem is that there is no such time as
 * midnight on the required date, and as such an exception is thrown.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param zone  the zone to use, null means default zone
 * @return this date as a datetime at midnight
 * @deprecated Use {@link #toDateTimeAtStartOfDay(DateTimeZone)} which won't throw an exception
 */
@Deprecated
public DateTime toDateTimeAtMidnight(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = getChronology().withZone(zone);
  return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono);
}

代码示例来源:origin: joda-time/joda-time

public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
  LocalDate check = LocalDate.fromDateFields(date);
  if (check.isBefore(this)) {

代码示例来源:origin: JodaOrg/joda-time

/**
 * Converts this LocalDate to a full datetime at midnight using the
 * specified time zone.
 * <p>
 * This method will throw an exception if the time zone switches
 * to Daylight Savings Time at midnight and this LocalDate represents
 * that switchover date. The problem is that there is no such time as
 * midnight on the required date, and as such an exception is thrown.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param zone  the zone to use, null means default zone
 * @return this date as a datetime at midnight
 * @deprecated Use {@link #toDateTimeAtStartOfDay(DateTimeZone)} which won't throw an exception
 */
@Deprecated
public DateTime toDateTimeAtMidnight(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = getChronology().withZone(zone);
  return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono);
}

代码示例来源:origin: apache/flink

@Override
public void write(Kryo kryo, Output output, LocalDate localDate) {
  output.writeInt(localDate.getYear());
  output.writeInt(localDate.getMonthOfYear());
  output.writeInt(localDate.getDayOfMonth());
  final Chronology chronology = localDate.getChronology();
  if (chronology != null && chronology != ISOChronology.getInstanceUTC()) {
    throw new RuntimeException("Unsupported chronology: " + chronology);
  }
}

代码示例来源:origin: JodaOrg/joda-time

public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
  LocalDate check = LocalDate.fromDateFields(date);
  if (check.isBefore(this)) {

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Wraps the other servicesRunning whose parameter is an OBA ServiceDate.
 * Joda LocalDate is a similar class.
 */
public BitSet servicesRunning (LocalDate date) {
  return servicesRunning(new ServiceDate(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth()));
}

代码示例来源:origin: killbill/killbill

@VisibleForTesting
DateTime getEffectiveDateForNewBCD(final int bcd, @Nullable final LocalDate effectiveFromDate, final InternalCallContext internalCallContext) {
  if (internalCallContext.getAccountRecordId() == null) {
    throw new IllegalStateException("Need to have a valid context with accountRecordId");
  }
  // Today as seen by this account
  final LocalDate startDate = effectiveFromDate != null ? effectiveFromDate : internalCallContext.toLocalDate(internalCallContext.getCreatedDate());
  // We want to compute a LocalDate in account TZ which maps to the provided 'bcd' and then compute an effectiveDate for when that BCD_CHANGE event needs to be triggered
  //
  // There is a bit of complexity to make sure the date we chose exists (e.g: a BCD of 31 in a february month would not make sense).
  final int currentDay = startDate.getDayOfMonth();
  final int lastDayOfMonth = startDate.dayOfMonth().getMaximumValue();
  final LocalDate requestedDate;
  if (bcd < currentDay) {
    final LocalDate startDatePlusOneMonth = startDate.plusMonths(1);
    final int lastDayOfNextMonth = startDatePlusOneMonth.dayOfMonth().getMaximumValue();
    final int originalBCDORLastDayOfMonth = bcd <= lastDayOfNextMonth ? bcd : lastDayOfNextMonth;
    requestedDate = new LocalDate(startDatePlusOneMonth.getYear(), startDatePlusOneMonth.getMonthOfYear(), originalBCDORLastDayOfMonth);
  } else if (bcd == currentDay && effectiveFromDate == null) {
    // will default to immediate event
    requestedDate = null;
  } else if (bcd <= lastDayOfMonth) {
    requestedDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), bcd);
  } else /* bcd > lastDayOfMonth && bcd > currentDay */ {
    requestedDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), lastDayOfMonth);
  }
  return requestedDate == null ? internalCallContext.getCreatedDate() : internalCallContext.toUTCDateTime(requestedDate);
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this LocalDate to a DateMidnight.
 * <p>
 * As from v1.5, you are recommended to avoid DateMidnight and use
 * {@link #toDateTimeAtStartOfDay()} instead because of the exception
 * detailed below.
 * <p>
 * This method will throw an exception if the time zone switches
 * to Daylight Savings Time at midnight and this LocalDate represents
 * that switchover date. The problem is that there is no such time as
 * midnight on the required date, and as such an exception is thrown.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param zone  the zone to get the DateMidnight in, null means default zone
 * @return the DateMidnight instance
 * @deprecated DateMidnight is deprecated
 */
@Deprecated
public DateMidnight toDateMidnight(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = getChronology().withZone(zone);
  return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Converts this LocalDate to a DateMidnight.
 * <p>
 * As from v1.5, you are recommended to avoid DateMidnight and use
 * {@link #toDateTimeAtStartOfDay()} instead because of the exception
 * detailed below.
 * <p>
 * This method will throw an exception if the time zone switches
 * to Daylight Savings Time at midnight and this LocalDate represents
 * that switchover date. The problem is that there is no such time as
 * midnight on the required date, and as such an exception is thrown.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param zone  the zone to get the DateMidnight in, null means default zone
 * @return the DateMidnight instance
 * @deprecated DateMidnight is deprecated
 */
@Deprecated
public DateMidnight toDateMidnight(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = getChronology().withZone(zone);
  return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}

代码示例来源:origin: killbill/killbill

public static LocalDate alignProposedBillCycleDate(final LocalDate proposedDate, final int billingCycleDay, final BillingPeriod billingPeriod) {
  // billingCycleDay alignment only makes sense for month based BillingPeriod (MONTHLY, QUARTERLY, BIANNUAL, ANNUAL)
  final boolean isMonthBased = (billingPeriod.getPeriod().getMonths() | billingPeriod.getPeriod().getYears()) > 0;
  if (!isMonthBased) {
    return proposedDate;
  }
  final int lastDayOfMonth = proposedDate.dayOfMonth().getMaximumValue();
  int proposedBillCycleDate = proposedDate.getDayOfMonth();
  if (proposedBillCycleDate < billingCycleDay) {
    if (billingCycleDay <= lastDayOfMonth) {
      proposedBillCycleDate = billingCycleDay;
    } else {
      proposedBillCycleDate = lastDayOfMonth;
    }
  }
  return new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(), proposedBillCycleDate, proposedDate.getChronology());
}

代码示例来源:origin: joda-time/joda-time

getYear(), getMonthOfYear(), getDayOfMonth(),
time.getHourOfDay(), time.getMinuteOfHour(),
time.getSecondOfMinute(), time.getMillisOfSecond(), chrono);

代码示例来源:origin: apache/flink

@Override
public void write(Kryo kryo, Output output, LocalDate object) {
  output.writeInt(object.getYear());
  output.writeInt(object.getMonthOfYear());
  output.writeInt(object.getDayOfMonth());
}

代码示例来源:origin: JodaOrg/joda-time

getYear(), getMonthOfYear(), getDayOfMonth(),
time.getHourOfDay(), time.getMinuteOfHour(),
time.getSecondOfMinute(), time.getMillisOfSecond(), chrono);

相关文章