Example usage for org.joda.time DateTimeConstants FEBRUARY

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

Introduction

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

Prototype

int FEBRUARY

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

Click Source Link

Document

Constant (2) representing February, the second month (ISO)

Usage

From source file:br.com.fidias.chance4j.Chance.java

License:Open Source License

/**
 * Generate a random datetime, limited to a year.
 *
 * @param year Year of the date//from  w  w  w  .  ja va2  s .  c om
 * @param hour Hour of the date
 * @param minute Minute of the date
 * @return A random date with time
 * @throws ChanceException
 */
private DateTime dateTime(int year, int hour, int minute, int second) throws ChanceException {
    int month = month();
    // https://github.com/JodaOrg/joda-time/issues/22
    int maximumValue;
    if (month == DateTimeConstants.FEBRUARY) {
        maximumValue = 28;
    } else {
        MonthDay monthDay = new MonthDay(month, 1);
        maximumValue = monthDay.dayOfMonth().getMaximumValue();
    }

    int day = natural(1, maximumValue);
    return new DateTime(year, month, day, hour, minute, second);
}

From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java

License:Open Source License

/**
 * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme annuel
 *
 * @param scheduler/*from  w w w  . j av a  2 s.c o m*/
 *       Instance de planificateur
 * @param date
 *       Derniere date d'xcution thorique
 *
 * @return LocalDate
 *       Prochaine date d'xcution
 */
private LocalDate getAnnualComputeDate(Scheduler scheduler, LocalDate date) {

    int monthOfYear = 0;

    if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JAN))
        monthOfYear = DateTimeConstants.JANUARY;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.FEB))
        monthOfYear = DateTimeConstants.FEBRUARY;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAR))
        monthOfYear = DateTimeConstants.MARCH;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.APR))
        monthOfYear = DateTimeConstants.APRIL;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.MAY))
        monthOfYear = DateTimeConstants.MAY;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUN))
        monthOfYear = DateTimeConstants.JUNE;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.JUL))
        monthOfYear = DateTimeConstants.JULY;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.AUG))
        monthOfYear = DateTimeConstants.AUGUST;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.SEP))
        monthOfYear = DateTimeConstants.SEPTEMBER;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.OCT))
        monthOfYear = DateTimeConstants.OCTOBER;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.NOV))
        monthOfYear = DateTimeConstants.NOVEMBER;
    else if (scheduler.getMonthAnnuallySelect().equals(IAdministration.DEC))
        monthOfYear = DateTimeConstants.DECEMBER;

    if (monthOfYear != 0) {

        int start = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMinimumValue();
        int end = date.plusWeeks(scheduler.getWeekWeekly()).dayOfMonth().getMaximumValue();

        if (start <= scheduler.getDayAnnually() && scheduler.getDayAnnually() <= end)
            return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear)
                    .withDayOfMonth(scheduler.getDayAnnually());
        else if (scheduler.getDayMonthly() < start)
            return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth()
                    .withMinimumValue();
        else if (scheduler.getDayMonthly() > end)
            return date.plusYears(scheduler.getYearAnnually()).withMonthOfYear(monthOfYear).dayOfMonth()
                    .withMaximumValue();

    }

    return null;

}

From source file:com.fourmob.datetimepicker.Utils.java

License:Open Source License

public static int getDaysInMonth(final int month, final int year) {

    switch (month) {
    default://from  w w  w .  j  ava2  s. c  o m
        throw new IllegalArgumentException("Invalid Month");
    case DateTimeConstants.JANUARY:
    case DateTimeConstants.MARCH:
    case DateTimeConstants.MAY:
    case DateTimeConstants.JULY:
    case DateTimeConstants.AUGUST:
    case DateTimeConstants.OCTOBER:
    case DateTimeConstants.DECEMBER:
        return 31;
    case DateTimeConstants.APRIL:
    case DateTimeConstants.JUNE:
    case DateTimeConstants.SEPTEMBER:
    case DateTimeConstants.NOVEMBER:
        return 30;
    case DateTimeConstants.FEBRUARY:
        if ((year % 4) == 0) {
            return 29;
        }
        return 28;
    }
}

From source file:com.helger.datetime.holiday.mgr.XMLUtil.java

License:Apache License

/**
 * Returns the {@link DateTimeConstants} value for the given month.
 * //from  www. j  a  va  2s .c o  m
 * @param eMonth
 *        Month of year to convert
 * @return {@link DateTimeConstants} value.
 */
@Nonnegative
public static int getMonth(@Nonnull final Month eMonth) {
    switch (eMonth) {
    case JANUARY:
        return DateTimeConstants.JANUARY;
    case FEBRUARY:
        return DateTimeConstants.FEBRUARY;
    case MARCH:
        return DateTimeConstants.MARCH;
    case APRIL:
        return DateTimeConstants.APRIL;
    case MAY:
        return DateTimeConstants.MAY;
    case JUNE:
        return DateTimeConstants.JUNE;
    case JULY:
        return DateTimeConstants.JULY;
    case AUGUST:
        return DateTimeConstants.AUGUST;
    case SEPTEMBER:
        return DateTimeConstants.SEPTEMBER;
    case OCTOBER:
        return DateTimeConstants.OCTOBER;
    case NOVEMBER:
        return DateTimeConstants.NOVEMBER;
    case DECEMBER:
        return DateTimeConstants.DECEMBER;
    default:
        throw new IllegalArgumentException("Unknown month " + eMonth);
    }
}

From source file:com.jjlharrison.jollyday.util.XMLUtil.java

License:Apache License

/**
 * Returns the <code>DateTimeConstants</code> value for the given month.
 *
 * @param month//from ww  w  .ja v  a  2 s.c o m
 *            a {@link com.jjlharrison.config.Month} object.
 * @return DateTimeConstants value.
 */
public int getMonth(Month month) {
    switch (month) {
    case JANUARY:
        return DateTimeConstants.JANUARY;
    case FEBRUARY:
        return DateTimeConstants.FEBRUARY;
    case MARCH:
        return DateTimeConstants.MARCH;
    case APRIL:
        return DateTimeConstants.APRIL;
    case MAY:
        return DateTimeConstants.MAY;
    case JUNE:
        return DateTimeConstants.JUNE;
    case JULY:
        return DateTimeConstants.JULY;
    case AUGUST:
        return DateTimeConstants.AUGUST;
    case SEPTEMBER:
        return DateTimeConstants.SEPTEMBER;
    case OCTOBER:
        return DateTimeConstants.OCTOBER;
    case NOVEMBER:
        return DateTimeConstants.NOVEMBER;
    case DECEMBER:
        return DateTimeConstants.DECEMBER;
    default:
        throw new IllegalArgumentException("Unknown month " + month);
    }
}

From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.SemLeidmiseAbimeetodid.java

License:Open Source License

/**
 *   Viib ajapunkti <tt>dateTime</tt> kvartali <tt>quarter</tt> keskmisele kuule. 
 *///  ww w  . j  a  v  a2s  .  c om
public static LocalDateTime setMiddleOfQuarterOfYear(LocalDateTime dateTime, String quarter) {
    if (quarter.equals("Q1")) {
        return dateTime.withMonthOfYear(DateTimeConstants.FEBRUARY);
    }
    if (quarter.equals("Q2")) {
        return dateTime.withMonthOfYear(DateTimeConstants.MAY);
    }
    if (quarter.equals("Q3")) {
        return dateTime.withMonthOfYear(DateTimeConstants.AUGUST);
    }
    if (quarter.equals("Q4")) {
        return dateTime.withMonthOfYear(DateTimeConstants.NOVEMBER);
    }
    return dateTime;
}

From source file:ee.ut.soras.ajavtV2.util.SemDefValjadeParsija.java

License:Open Source License

/**
 *   Tagastab s6nele vastava konstandi klassist <tt>org.joda.time.DateTimeConstants</tt>.
 *//*from www . j  a va2 s  .com*/
public static int parseValueFromConstant(String dateTimeConstant) {
    // -------------------      AM_PM     ------------------------
    if (dateTimeConstant.equals("AM")) {
        return DateTimeConstants.AM;
    }
    if (dateTimeConstant.equals("PM")) {
        return DateTimeConstants.PM;
    }
    // -------------------  Nadalapaevad  ------------------------
    if (dateTimeConstant.equals("MONDAY")) {
        return DateTimeConstants.MONDAY;
    }
    if (dateTimeConstant.equals("TUESDAY")) {
        return DateTimeConstants.TUESDAY;
    }
    if (dateTimeConstant.equals("WEDNESDAY")) {
        return DateTimeConstants.WEDNESDAY;
    }
    if (dateTimeConstant.equals("THURSDAY")) {
        return DateTimeConstants.THURSDAY;
    }
    if (dateTimeConstant.equals("FRIDAY")) {
        return DateTimeConstants.FRIDAY;
    }
    if (dateTimeConstant.equals("SATURDAY")) {
        return DateTimeConstants.SATURDAY;
    }
    if (dateTimeConstant.equals("SUNDAY")) {
        return DateTimeConstants.SUNDAY;
    }
    // ---------------------  Kuud  ------------------------------
    if (dateTimeConstant.equals("JANUARY")) {
        return DateTimeConstants.JANUARY;
    }
    if (dateTimeConstant.equals("FEBRUARY")) {
        return DateTimeConstants.FEBRUARY;
    }
    if (dateTimeConstant.equals("MARCH")) {
        return DateTimeConstants.MARCH;
    }
    if (dateTimeConstant.equals("APRIL")) {
        return DateTimeConstants.APRIL;
    }
    if (dateTimeConstant.equals("MAY")) {
        return DateTimeConstants.MAY;
    }
    if (dateTimeConstant.equals("JUNE")) {
        return DateTimeConstants.JUNE;
    }
    if (dateTimeConstant.equals("JULY")) {
        return DateTimeConstants.JULY;
    }
    if (dateTimeConstant.equals("AUGUST")) {
        return DateTimeConstants.AUGUST;
    }
    if (dateTimeConstant.equals("SEPTEMBER")) {
        return DateTimeConstants.SEPTEMBER;
    }
    if (dateTimeConstant.equals("OCTOBER")) {
        return DateTimeConstants.OCTOBER;
    }
    if (dateTimeConstant.equals("NOVEMBER")) {
        return DateTimeConstants.NOVEMBER;
    }
    if (dateTimeConstant.equals("DECEMBER")) {
        return DateTimeConstants.DECEMBER;
    }
    return Integer.MIN_VALUE;
}