Example usage for org.joda.time MonthDay MonthDay

List of usage examples for org.joda.time MonthDay MonthDay

Introduction

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

Prototype

MonthDay(MonthDay partial, Chronology chrono) 

Source Link

Document

Constructs a MonthDay with values from this instance and a new chronology.

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  .  jav  a  2 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.fusesource.examples.horo.model.StarSign.java

License:Apache License

private StarSign(String signName, Integer startMonth, Integer startDay, Integer endMonth, Integer endDay) {
    Validate.notEmpty(signName, "signName is empty");
    Validate.notNull(startMonth, "startMonth is null");
    Validate.notNull(startDay, "startDay is null");
    Validate.notNull(endMonth, "endMonth is null");
    Validate.notNull(endDay, "endDay is null");

    this.name = signName;
    // year is intended to be ignored
    this.start = new MonthDay(startMonth, startDay);
    this.end = new MonthDay(endMonth, endDay);
}

From source file:com.gst.portfolio.charge.domain.Charge.java

License:Apache License

public MonthDay getFeeOnMonthDay() {
    MonthDay feeOnMonthDay = null;
    if (this.feeOnDay != null && this.feeOnMonth != null) {
        feeOnMonthDay = new MonthDay(this.feeOnMonth, this.feeOnDay);
    }/*ww w  . j a va 2  s  .  com*/
    return feeOnMonthDay;
}

From source file:fr.nicopico.dashclock.birthday.data.BirthdayRetriever.java

License:Apache License

private Birthday buildBirthday(ContentResolver contentResolver, Cursor c) {
    String birthDate = c.getString(1);
    if (birthDate == null)
        return null;

    // Analyze birthday string
    try {/*from  w  w  w.  j a  v a  2s  .  c  o m*/
        Matcher regexMatcher = regexDate.matcher(birthDate);

        if (regexMatcher.find()) {
            Birthday birthday = new Birthday(contentResolver, c.getLong(0));

            // Birthday *must* have a display name
            if (birthday.displayName == null)
                return null;

            birthday.birthdayDate = new MonthDay(Integer.parseInt(regexMatcher.group(2)),
                    Integer.parseInt(regexMatcher.group(3)));

            if (!"-".equals(regexMatcher.group(1))) {
                birthday.year = Integer.parseInt(regexMatcher.group(1));
                birthday.unknownYear = false;
            }

            return birthday;
        }
    } catch (Exception e) {
        Log.e(TAG, "Error while analyzing birthday", e);
        return null;
    }

    return null;
}

From source file:org.apereo.portal.events.aggr.EventDateTimeUtils.java

License:Apache License

/**
 * Create a new set of quarter details in the standard 1/1-4/1, 4/1-7/1, 7/1-10/1, 10/1-1/1
 * arrangement//from  w  w  w  .  jav a 2  s .  com
 */
public static List<QuarterDetail> createStandardQuarters() {
    return ImmutableList.<QuarterDetail>of(new QuarterDetailImpl(new MonthDay(1, 1), new MonthDay(4, 1), 0),
            new QuarterDetailImpl(new MonthDay(4, 1), new MonthDay(7, 1), 1),
            new QuarterDetailImpl(new MonthDay(7, 1), new MonthDay(10, 1), 2),
            new QuarterDetailImpl(new MonthDay(10, 1), new MonthDay(1, 1), 3));
}