List of usage examples for org.joda.time LocalDate getMonthOfYear
public int getMonthOfYear()
From source file:com.google.ical.compat.jodatime.LocalDateIteratorFactory.java
License:Apache License
static DateValue localDateToDateValue(LocalDate date) { return new DateValueImpl(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth()); }
From source file:com.google.walkaround.wave.server.googleimport.FindRemoteWavesProcessor.java
License:Open Source License
private String getQueryDateRestriction(String facet, long dateDays) { LocalDate date = DaysSinceEpoch.toLocalDate(dateDays); return String.format("%s:%04d/%02d/%02d", facet, date.getYear(), date.getMonthOfYear(), date.getDayOfMonth());/*from w ww . j a v a 2 s .co m*/ }
From source file:com.gst.infrastructure.core.api.JodaLocalDateAdapter.java
License:Apache License
@SuppressWarnings("unused") @Override/* w w w . j a v a2 s . co m*/ public JsonElement serialize(final LocalDate src, final Type typeOfSrc, final JsonSerializationContext context) { JsonArray array = null; if (src != null) { array = new JsonArray(); array.add(new JsonPrimitive(src.getYearOfEra())); array.add(new JsonPrimitive(src.getMonthOfYear())); array.add(new JsonPrimitive(src.getDayOfMonth())); } return array; }
From source file:com.gst.infrastructure.dataqueries.service.GenericDataServiceImpl.java
License:Apache License
@Override public String generateJsonFromGenericResultsetData(final GenericResultsetData grs) { final StringBuffer writer = new StringBuffer(); writer.append("["); final List<ResultsetColumnHeaderData> columnHeaders = grs.getColumnHeaders(); final List<ResultsetRowData> data = grs.getData(); List<String> row; Integer rSize;/* w ww . j a v a 2 s . c o m*/ final String doubleQuote = "\""; final String slashDoubleQuote = "\\\""; String currColType; String currVal; for (int i = 0; i < data.size(); i++) { writer.append("\n{"); row = data.get(i).getRow(); rSize = row.size(); for (int j = 0; j < rSize; j++) { writer.append(doubleQuote + columnHeaders.get(j).getColumnName() + doubleQuote + ": "); currColType = columnHeaders.get(j).getColumnDisplayType(); final String colType = columnHeaders.get(j).getColumnType(); if (currColType == null && colType.equalsIgnoreCase("INT")) { currColType = "INTEGER"; } if (currColType == null && colType.equalsIgnoreCase("VARCHAR")) { currColType = "VARCHAR"; } if (currColType == null && colType.equalsIgnoreCase("DATE")) { currColType = "DATE"; } currVal = row.get(j); if (currVal != null && currColType != null) { if (currColType.equals("DECIMAL") || currColType.equals("INTEGER")) { writer.append(currVal); } else { if (currColType.equals("DATE")) { final LocalDate localDate = new LocalDate(currVal); writer.append("[" + localDate.getYear() + ", " + localDate.getMonthOfYear() + ", " + localDate.getDayOfMonth() + "]"); } else if (currColType.equals("DATETIME")) { final LocalDateTime localDateTime = new LocalDateTime(currVal); writer.append("[" + localDateTime.getYear() + ", " + localDateTime.getMonthOfYear() + ", " + localDateTime.getDayOfMonth() + " " + localDateTime.getHourOfDay() + ", " + localDateTime.getMinuteOfHour() + ", " + localDateTime.getSecondOfMinute() + ", " + localDateTime.getMillisOfSecond() + "]"); } else { writer.append( doubleQuote + replace(currVal, doubleQuote, slashDoubleQuote) + doubleQuote); } } } else { writer.append("null"); } if (j < (rSize - 1)) { writer.append(",\n"); } } if (i < (data.size() - 1)) { writer.append("},"); } else { writer.append("}"); } } writer.append("\n]"); return writer.toString(); }
From source file:com.gst.portfolio.calendar.service.CalendarUtils.java
License:Apache License
public static LocalDate adjustDate(final LocalDate date, final LocalDate seedDate, final PeriodFrequencyType frequencyType) { LocalDate adjustedVal = date; if (frequencyType.isMonthly() && seedDate.getDayOfMonth() > 28) { switch (date.getMonthOfYear()) { case 2://from w w w . ja v a 2 s .c om if (date.year().isLeap()) { adjustedVal = date.dayOfMonth().setCopy(29); } break; case 4: case 6: case 9: case 11: if (seedDate.getDayOfMonth() > 30) { adjustedVal = date.dayOfMonth().setCopy(30); } else { adjustedVal = date.dayOfMonth().setCopy(seedDate.getDayOfMonth()); } break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: adjustedVal = date.dayOfMonth().setCopy(seedDate.getDayOfMonth()); break; } } return adjustedVal; }
From source file:com.gst.portfolio.savings.domain.interest.PostingPeriod.java
License:Apache License
private static LocalDate determineInterestPeriodEndDateFrom(final LocalDate periodStartDate, final SavingsCompoundingInterestPeriodType interestPeriodType, final LocalDate upToInterestCalculationDate) { LocalDate periodEndDate = upToInterestCalculationDate; switch (interestPeriodType) { case INVALID: break;/*from w ww . j a va 2 s .com*/ case DAILY: periodEndDate = periodStartDate; break; // case WEEKLY: // periodEndDate = periodStartDate.dayOfWeek().withMaximumValue(); // break; // case BIWEEKLY: // final LocalDate closestEndOfWeek = // periodStartDate.dayOfWeek().withMaximumValue(); // periodEndDate = closestEndOfWeek.plusWeeks(1); // break; case MONTHLY: // produce period end date on last day of current month periodEndDate = periodStartDate.dayOfMonth().withMaximumValue(); break; case QUATERLY: // // jan 1st to mar 31st, 1st apr to jun 30, jul 1st to sept // 30, // // oct 1st to dec 31 int year = periodStartDate.getYearOfEra(); int monthofYear = periodStartDate.getMonthOfYear(); if (monthofYear <= 3) { periodEndDate = new DateTime().withDate(year, 3, 31).toLocalDate(); } else if (monthofYear <= 6) { periodEndDate = new DateTime().withDate(year, 6, 30).toLocalDate(); } else if (monthofYear <= 9) { periodEndDate = new DateTime().withDate(year, 9, 30).toLocalDate(); } else if (monthofYear <= 12) { periodEndDate = new DateTime().withDate(year, 12, 31).toLocalDate(); } break; case BI_ANNUAL: // // jan 1st to 30, jul 1st to dec 31 year = periodStartDate.getYearOfEra(); monthofYear = periodStartDate.getMonthOfYear(); if (monthofYear <= 6) { periodEndDate = new DateTime().withDate(year, 6, 30).toLocalDate(); } else if (monthofYear <= 12) { periodEndDate = new DateTime().withDate(year, 12, 31).toLocalDate(); } break; case ANNUAL: periodEndDate = periodStartDate.monthOfYear().withMaximumValue(); periodEndDate = periodEndDate.dayOfMonth().withMaximumValue(); break; // case NO_COMPOUNDING_SIMPLE_INTEREST: // periodEndDate = periodStartDate.monthOfYear().withMaximumValue(); // periodEndDate = periodEndDate.dayOfMonth().withMaximumValue(); // break; } return periodEndDate; }
From source file:com.gst.portfolio.savings.domain.SavingsHelper.java
License:Apache License
private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate periodStartDate, final SavingsPostingInterestPeriodType interestPostingPeriodType, final LocalDate interestPostingUpToDate, Integer financialYearBeginningMonth) { LocalDate periodEndDate = interestPostingUpToDate; final Integer monthOfYear = periodStartDate.getMonthOfYear(); financialYearBeginningMonth--;//from ww w . ja v a 2 s.c o m if (financialYearBeginningMonth == 0) financialYearBeginningMonth = 12; final ArrayList<LocalDate> quarterlyDates = new ArrayList<>(); quarterlyDates .add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue()); quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(3) .withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue()); quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6) .withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue()); quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(9) .withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue()); Collections.sort(quarterlyDates); final ArrayList<LocalDate> biannualDates = new ArrayList<>(); biannualDates .add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue()); biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6) .withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue()); Collections.sort(biannualDates); boolean isEndDateSet = false; switch (interestPostingPeriodType) { case INVALID: break; case MONTHLY: // produce period end date on last day of current month periodEndDate = periodStartDate.dayOfMonth().withMaximumValue(); break; case QUATERLY: for (LocalDate quarterlyDate : quarterlyDates) { if (quarterlyDate.isAfter(periodStartDate)) { periodEndDate = quarterlyDate; isEndDateSet = true; break; } } if (!isEndDateSet) periodEndDate = quarterlyDates.get(0).plusYears(1).dayOfMonth().withMaximumValue(); break; case BIANNUAL: for (LocalDate biannualDate : biannualDates) { if (biannualDate.isAfter(periodStartDate)) { periodEndDate = biannualDate; isEndDateSet = true; break; } } if (!isEndDateSet) periodEndDate = biannualDates.get(0).plusYears(1).dayOfMonth().withMaximumValue(); break; case ANNUAL: if (financialYearBeginningMonth < monthOfYear) { periodEndDate = periodStartDate.withMonthOfYear(financialYearBeginningMonth); periodEndDate = periodEndDate.plusYears(1); } else { periodEndDate = periodStartDate.withMonthOfYear(financialYearBeginningMonth); } periodEndDate = periodEndDate.dayOfMonth().withMaximumValue(); break; } // interest posting always occurs on next day after the period end date. periodEndDate = periodEndDate.plusDays(1); return periodEndDate; }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth()); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, 0, 0);//w w w .j a va2s .c o m }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes, final int nSeconds) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, nSeconds, 0);//from ww w. j a va 2 s .c o m }