本文整理了Java中org.joda.time.LocalDate.dayOfMonth()
方法的一些代码示例,展示了LocalDate.dayOfMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.dayOfMonth()
方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:dayOfMonth
[英]Get the day of month property which provides access to advanced functionality.
[中]获取提供高级功能访问权限的day of month属性。
代码示例来源: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: org.codehaus.jackson/jackson-mapper-asl
@Override
public void serialize(LocalDate dt, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
// Timestamp here actually means an array of values
jgen.writeStartArray();
jgen.writeNumber(dt.year().get());
jgen.writeNumber(dt.monthOfYear().get());
jgen.writeNumber(dt.dayOfMonth().get());
jgen.writeEndArray();
} else {
jgen.writeString(printLocalDate(dt));
}
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda
@Override
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider provider) throws IOException
{
if (_serializationShape(provider) == FORMAT_STRING) {
gen.writeString(_format.createFormatter(provider).print(value));
return;
}
// 28-Jul-2017, tatu: Wrt [dataformat-joda#39]... we could perhaps support timestamps,
// but only by specifying what to do with time (`LocalTime`) AND timezone. For now,
// seems like asking for trouble really... so only use array notation.
gen.writeStartArray();
gen.writeNumber(value.year().get());
gen.writeNumber(value.monthOfYear().get());
gen.writeNumber(value.dayOfMonth().get());
gen.writeEndArray();
}
}
代码示例来源:origin: stackoverflow.com
// Parse using DateTimeFormatter.parseDateTime().toLocalDate();
LocalDate original = ...;
LocalDate startOfMonth = original.dayOfMonth().withMinimumValue();
LocalDate endOfMonth = original.dayOfMonth().withMaximumValue();
代码示例来源:origin: stackoverflow.com
public static final int JANUARY = 1;
public static final int DECEMBER = 12;
public static final int FIRST_OF_THE_MONTH = 1;
public final int getLastDayOfMonth(final int month, final int year) {
int lastDay = 0;
if ((month >= JANUARY) && (month <= DECEMBER)) {
LocalDate aDate = new LocalDate(year, month, FIRST_OF_THE_MONTH);
lastDay = aDate.dayOfMonth().getMaximumValue();
}
return lastDay;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void serialize(LocalDate dt, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
if (provider.isEnabled(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS)) {
// Timestamp here actually means an array of values
jgen.writeStartArray();
jgen.writeNumber(dt.year().get());
jgen.writeNumber(dt.monthOfYear().get());
jgen.writeNumber(dt.dayOfMonth().get());
jgen.writeEndArray();
} else {
jgen.writeString(printLocalDate(dt));
}
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public int getRowCount(int column) {
int nbYears = (firstMonth + column - 1) / 12;
LocalDate date = new LocalDate(year + nbYears, (firstMonth + column - 1) % 12 + 1, 1);
return date.dayOfMonth().getMaximumValue();
}
代码示例来源:origin: googleads/aw-reporting
/**
* Get a LocalDate for the first day of a month.
* @return LocalDate
*/
public static LocalDate firstDayMonth(LocalDate localDate) {
return localDate.dayOfMonth().withMinimumValue();
}
代码示例来源:origin: googleads/aw-reporting
/**
* Get a LocalDate for the last day of a month.
* @return LocalDate
*/
public static LocalDate lastDayMonth(LocalDate localDate) {
return localDate.dayOfMonth().withMaximumValue();
}
}
代码示例来源:origin: googleads/aw-reporting
/**
* Get a LocalDate for the first day of the previous month.
* @return LocalDate
*/
public static LocalDate firstDayPreviousMonth() {
return new LocalDate().minusMonths(1).dayOfMonth().withMinimumValue();
}
代码示例来源:origin: nl.cloudfarming.client/calendar-api
public static DateBounds getMonthBounds(LocalDate actualDate) {
LocalDate lowBound = actualDate.dayOfMonth().withMinimumValue();
LocalDate hiBound = actualDate.dayOfMonth().withMaximumValue();
return new DateBounds(lowBound, hiBound);
}
代码示例来源:origin: googleads/aw-reporting
/**
* Get a LocalDate for the last day of the previous month.
* @return LocalDate
*/
public static LocalDate lastDayPreviousMonth() {
return new LocalDate().minusMonths(1).dayOfMonth().withMaximumValue();
}
代码示例来源:origin: fluxtream/fluxtream-app
public static LocalDate getEndOfMonth(final int year, final int month) {
return (new LocalDate())
.withWeekyear(year)
.withMonthOfYear(month).dayOfMonth().withMaximumValue();
}
代码示例来源:origin: fluxtream/fluxtream-app
public static LocalDate getBeginningOfMonth(final int year, final int month) {
return (new LocalDate())
.withWeekyear(year)
.withMonthOfYear(month).dayOfMonth().withMinimumValue();
}
代码示例来源:origin: com.ning.billing/killbill-invoice
private LocalDate alignProposedBillCycleDate(final LocalDate proposedDate) {
if (!shouldUsePatch) {
return proposedDate;
}
final int lastDayOfMonth = proposedDate.dayOfMonth().getMaximumValue();
int proposedBillCycleDate = proposedDate.getDayOfMonth();
if (proposedBillCycleDate < billingCycleDay && billingCycleDay <= lastDayOfMonth) {
proposedBillCycleDate = billingCycleDay;
}
return new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(), proposedBillCycleDate, proposedDate.getChronology());
}
}
代码示例来源:origin: com.synaptix/SynaptixWidget
private void init() {
LocalDate firstDate = new LocalDate(year, month, 1);
startDate = firstDate.withDayOfWeek(DateTimeConstants.MONDAY);
LocalDate lastDate = firstDate.withDayOfMonth(firstDate.dayOfMonth().getMaximumValue());
LocalDate endDate;
if (lastDate.getDayOfWeek() != DateTimeConstants.SUNDAY) {
endDate = lastDate.withDayOfWeek(DateTimeConstants.SUNDAY);
} else {
endDate = lastDate;
}
Duration d = new Duration(startDate.toDateMidnight(DateTimeZone.UTC), endDate.toDateMidnight(DateTimeZone.UTC));
nbWeek = ((int) d.getStandardDays() + 1) / 7;
}
代码示例来源:origin: com.ning.billing/killbill-invoice
public static LocalDate calculateBillingCycleDateOnOrAfter(final LocalDate date, final int billingCycleDayLocal) {
final int lastDayOfMonth = date.dayOfMonth().getMaximumValue();
final LocalDate fixedDate;
if (billingCycleDayLocal > lastDayOfMonth) {
fixedDate = new LocalDate(date.getYear(), date.getMonthOfYear(), lastDayOfMonth, date.getChronology());
} else {
fixedDate = new LocalDate(date.getYear(), date.getMonthOfYear(), billingCycleDayLocal, date.getChronology());
}
LocalDate proposedDate = fixedDate;
while (proposedDate.isBefore(date)) {
proposedDate = proposedDate.plusMonths(1);
}
return proposedDate;
}
代码示例来源:origin: net.objectlab.kit/datecalc-joda
private int diff360EIsda(final LocalDate start, final LocalDate end) {
if (start.equals(end)) {
return 0;
}
int dayStart = start.getDayOfMonth();
int dayEnd = end.getDayOfMonth();
if (start.dayOfMonth().getMaximumValue() == dayStart) {
dayStart = CalculatorConstants.MONTH_30_DAYS;
}
if (end.getMonthOfYear() != 2 && end.dayOfMonth().getMaximumValue() == dayEnd) {
dayEnd = CalculatorConstants.MONTH_30_DAYS;
}
return (end.getYear() - start.getYear()) * CalculatorConstants.YEAR_360 + (end.getMonthOfYear() - start.getMonthOfYear()) * CalculatorConstants.MONTH_30_DAYS + dayEnd - dayStart;
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
private void calculateFirstBillingCycleDate() {
final int lastDayOfMonth = startDate.dayOfMonth().getMaximumValue();
final LocalDate billingCycleDate;
if (billingCycleDay > lastDayOfMonth) {
billingCycleDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), lastDayOfMonth, startDate.getChronology());
} else {
billingCycleDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), billingCycleDay, startDate.getChronology());
}
LocalDate proposedDate = billingCycleDate;
while (proposedDate.isBefore(startDate)) {
proposedDate = proposedDate.plus(billingPeriod.getPeriod());
}
firstBillingCycleDate = BillCycleDayCalculator.alignProposedBillCycleDate(proposedDate, billingCycleDay, billingPeriod);
}
内容来源于网络,如有侵权,请联系作者删除!