List of usage examples for org.joda.time LocalDate getChronology
public Chronology getChronology()
From source file:com.jjlharrison.jollyday.util.CalendarUtil.java
License:Apache License
/** * Converts the provided date into a date within the ISO chronology. If it * is already a ISO date it will return it. * * @param date// ww w . j a v a 2 s .co m * a {@link org.joda.time.LocalDate} object. * @return a {@link org.joda.time.LocalDate} object. */ public LocalDate convertToISODate(final LocalDate date) { if (!(date.getChronology() instanceof ISOChronology)) { return new LocalDate(date.toDateTimeAtStartOfDay().getMillis(), ISOChronology.getInstance()); } return date; }
From source file:com.ning.billing.invoice.generator.InvoiceDateUtils.java
License:Apache License
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 {//w w w .jav a2 s . com fixedDate = new LocalDate(date.getYear(), date.getMonthOfYear(), billingCycleDayLocal, date.getChronology()); } LocalDate proposedDate = fixedDate; while (proposedDate.isBefore(date)) { proposedDate = proposedDate.plusMonths(1); } return proposedDate; }
From source file:de.javakaffee.kryoserializers.jodatime.JodaLocalDateSerializer.java
License:Apache License
@Override public void write(final Kryo kryo, final Output output, final LocalDate localDate) { final int packedYearMonthDay = localDate.getYear() * 13 * 32 + localDate.getMonthOfYear() * 32 + localDate.getDayOfMonth(); output.writeInt(packedYearMonthDay, true); final String chronologyId = IdentifiableChronology.getChronologyId(localDate.getChronology()); output.writeString(chronologyId == null ? "" : chronologyId); }
From source file:org.killbill.billing.invoice.generator.BillingIntervalDetail.java
License:Apache License
public static LocalDate alignProposedBillCycleDate(final LocalDate proposedDate, final int billingCycleDay) { final int lastDayOfMonth = proposedDate.dayOfMonth().getMaximumValue(); int proposedBillCycleDate = proposedDate.getDayOfMonth(); if (proposedBillCycleDate < billingCycleDay && billingCycleDay <= lastDayOfMonth) { proposedBillCycleDate = billingCycleDay; }//w ww . jav a 2 s. c o m return new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(), proposedBillCycleDate, proposedDate.getChronology()); }
From source file:org.killbill.billing.util.bcd.BillCycleDayCalculator.java
License:Apache License
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; }// ww w . j a v a 2 s .co m 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()); }