本文整理了Java中org.joda.time.LocalDate.getDayOfMonth()
方法的一些代码示例,展示了LocalDate.getDayOfMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.getDayOfMonth()
方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:getDayOfMonth
[英]Get the day of month field value.
The values for the day of month are defined in org.joda.time.DateTimeConstants.
[中]获取月日字段值。
月日的值在组织中定义。乔达。时间DateTimeConstants。
代码示例来源: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 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: killbill/killbill
private static int calculateBcdFromSubscription(final SubscriptionBase subscription, final InternalTenantContext internalTenantContext) {
final DateTime date = subscription.getDateOfFirstRecurringNonZeroCharge();
final int bcdLocal = internalTenantContext.toLocalDate(date).getDayOfMonth();
log.debug("Calculated BCD: subscriptionId='{}', subscriptionStartDate='{}', bcd='{}'",
subscription.getId(), date.toDateTimeISO(), bcdLocal);
return bcdLocal;
}
}
代码示例来源:origin: joda-time/joda-time
advance = (day != -1 && dayOfWeek != 0);
month = date.getMonthOfYear();
day = date.getDayOfMonth();
if (dayOfWeek != 0) {
dayOfWeek = ((dayOfWeek - 1 + 1) % 7) + 1;
代码示例来源:origin: JodaOrg/joda-time
advance = (day != -1 && dayOfWeek != 0);
month = date.getMonthOfYear();
day = date.getDayOfMonth();
if (dayOfWeek != 0) {
dayOfWeek = ((dayOfWeek - 1 + 1) % 7) + 1;
代码示例来源: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
int dom = getDayOfMonth();
Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
LocalDate check = LocalDate.fromDateFields(date);
代码示例来源: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
int dom = getDayOfMonth();
Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
LocalDate check = LocalDate.fromDateFields(date);
代码示例来源: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: 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
@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: 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);
内容来源于网络,如有侵权,请联系作者删除!