List of usage examples for org.joda.time DateTime plusMonths
public DateTime plusMonths(int months)
From source file:kr.debop4j.timeperiod.timerange.MonthTimeRange.java
License:Apache License
private static ITimePeriod getPeriodOf(int year, int month, int monthCount) { assert monthCount > 0; DateTime start = new DateTime(year, month, 1, 0, 0); return new TimeRange(start, start.plusMonths(monthCount)); }
From source file:kr.debop4j.timeperiod.timerange.QuarterTimeRange.java
License:Apache License
/** * Gets months./*from w w w . j av a 2 s . c om*/ * * @return the months */ public List<MonthRange> getMonths() { DateTime startMonth = new DateTime(startYear, 1, 1, 0, 0); int monthCount = quarterCount * TimeSpec.MonthsPerQuarter; List<MonthRange> months = Lists.newArrayListWithCapacity(monthCount); for (int m = 0; m < monthCount; m++) { months.add(new MonthRange(startMonth.plusMonths(m), getTimeCalendar())); } return months; }
From source file:kr.debop4j.timeperiod.timerange.QuarterTimeRange.java
License:Apache License
private static ITimePeriod getPeriodOf(int year, Quarter quarterKind, int quarterCount, ITimeCalendar calendar) {/*from w ww. j a va 2 s .c o m*/ assert quarterCount >= 0; int quarter = quarterKind.getValue(); DateTime yearStart = new DateTime(year, 1, 1, 0, 0); DateTime start = yearStart.plusMonths((quarter - 1) * TimeSpec.MonthsPerQuarter); DateTime end = start.plusMonths(quarterCount * TimeSpec.MonthsPerQuarter); return new TimeRange(start, end); }
From source file:kr.debop4j.timeperiod.timerange.YearTimeRange.java
License:Apache License
/** * Gets months./* w w w.j a v a2s . c om*/ * * @return the months */ public List<MonthRange> getMonths() { int startYear = getStartYear(); List<MonthRange> months = Lists.newArrayListWithCapacity(yearCount * TimeSpec.MonthsPerYear); int monthCount = getYearCount() * TimeSpec.MonthsPerYear; DateTime startDate = Times.startTimeOfYear(getStartYear()); for (int m = 0; m < monthCount; m++) { months.add(new MonthRange(startDate.plusMonths(m), getTimeCalendar())); } return months; }
From source file:kr.debop4j.timeperiod.tools.Durations.java
License:Apache License
/** * Halfyear duration.//from w w w .j a v a 2s.c om * * @param year the year * @param halfyear the halfyear * @return the duration */ public static Duration halfyear(int year, Halfyear halfyear) { DateTime start = startTimeOfHalfyear(year, halfyear); DateTime end = start.plusMonths(TimeSpec.MonthsPerHalfyear); return new Duration(start, end); }
From source file:kr.debop4j.timeperiod.tools.Durations.java
License:Apache License
/** * Quarter duration./*w ww.j a v a 2 s.com*/ * * @param year the year * @param quarter the quarter * @return the duration */ public static Duration quarter(int year, Quarter quarter) { DateTime start = startTimeOfQuarter(year, quarter); DateTime end = start.plusMonths(TimeSpec.MonthsPerQuarter); return new Duration(start, end); }
From source file:kr.debop4j.timeperiod.tools.Durations.java
License:Apache License
/** * Month duration.//from ww w. j ava 2s. co m * * @param year the year * @param monthOfYear the month of year * @return the duration */ public static Duration month(int year, int monthOfYear) { DateTime start = Times.startTimeOfMonth(year, monthOfYear); DateTime end = start.plusMonths(1); return new Duration(start, end); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** * Gets days in month.//from w w w . j av a2 s . c om * * @param year the year * @param month the month * @return the days in month */ public static int getDaysInMonth(int year, int month) { DateTime firstDay = new DateTime(year, month, 1, 0, 0); return firstDay.plusMonths(1).plusDays(-1).getDayOfMonth(); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ? (months) ?? */ public static TimeRange getRelativeMonthPeriod(DateTime start, int months) { return getTimeRange(start, start.plusMonths(months)); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ? ? . */ public static List<ITimePeriod> foreachHalfyears(ITimePeriod period) { assert period != null; if (isTraceEnabled) log.trace("[{}]? Halfyear ...", period); List<ITimePeriod> halfyears = Lists.newArrayList(); if (period.isAnytime()) return halfyears; assertHasPeriod(period);// w w w. j ava 2 s.c o m if (Times.isSameHalfyear(period.getStart(), period.getEnd())) { halfyears.add(new TimeRange(period)); return halfyears; } DateTime current = Times.endTimeOfHalfyear(period.getStart()); halfyears.add(new TimeRange(period.getStart(), current)); int endHashCode = period.getEnd().getYear() * 10 + Times.halfyearOf(period.getEnd()).getValue(); current = current.plusDays(1); ITimeCalendar calendar = TimeCalendar.getDefault(); while (current.getYear() * 10 + Times.halfyearOf(current).getValue() < endHashCode) { halfyears.add(Times.getHalfyearRange(current, calendar)); current = current.plusMonths(TimeSpec.MonthsPerHalfyear); } if (current.compareTo(period.getEnd()) < 0) { halfyears.add(new TimeRange(Times.startTimeOfHalfyear(current), period.getEnd())); } return halfyears; }