Example usage for org.joda.time DateTimeConstants APRIL

List of usage examples for org.joda.time DateTimeConstants APRIL

Introduction

In this page you can find the example usage for org.joda.time DateTimeConstants APRIL.

Prototype

int APRIL

To view the source code for org.joda.time DateTimeConstants APRIL.

Click Source Link

Document

Constant (4) representing April, the fourth month (ISO)

Usage

From source file:org.kemri.wellcome.dhisreport.api.utils.QuarterlyPeriod.java

License:Open Source License

/**
 * TODO: Probably more efficient ways to do this. But this is least cryptic
 * @param date //from   w  w w.  j a va  2s .  co  m
 */
public QuarterlyPeriod(Date date) {
    DateTime dt = new DateTime(date);
    int monthNum = dt.getMonthOfYear();
    if (monthNum >= 1 && monthNum <= 3) {
        startDate = dt.withMonthOfYear(DateTimeConstants.JANUARY).dayOfMonth().withMinimumValue().toDate();
        endDate = dt.withMonthOfYear(DateTimeConstants.MARCH).dayOfMonth().withMaximumValue()
                .withTime(23, 59, 59, 999).toDate();
    } else if (monthNum >= 4 && monthNum <= 6) {
        startDate = dt.withMonthOfYear(DateTimeConstants.APRIL).dayOfMonth().withMinimumValue().toDate();
        endDate = dt.withMonthOfYear(DateTimeConstants.JUNE).dayOfMonth().withMaximumValue()
                .withTime(23, 59, 59, 999).toDate();
    } else if (monthNum >= 7 && monthNum <= 9) {
        startDate = dt.withMonthOfYear(DateTimeConstants.JULY).dayOfMonth().withMinimumValue().toDate();
        endDate = dt.withMonthOfYear(DateTimeConstants.SEPTEMBER).dayOfMonth().withMaximumValue()
                .withTime(23, 59, 59, 999).toDate();
    } else if (monthNum >= 10 && monthNum <= 12) {
        startDate = dt.withMonthOfYear(DateTimeConstants.OCTOBER).dayOfMonth().withMinimumValue().toDate();
        endDate = dt.withMonthOfYear(DateTimeConstants.DECEMBER).dayOfMonth().withMaximumValue()
                .withTime(23, 59, 59, 999).toDate();
    }
}