Example usage for org.joda.time.base BaseDateTime getYear

List of usage examples for org.joda.time.base BaseDateTime getYear

Introduction

In this page you can find the example usage for org.joda.time.base BaseDateTime getYear.

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:com.foundationdb.server.types.mcompat.mtypes.MDateAndTime.java

License:Open Source License

/** Pass components of {@code dt} to {@link #encodeDateTime(long, long, long, long, long, long)}. */
public static long encodeDateTime(BaseDateTime dt) {
    return encodeDateTime(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), dt.getHourOfDay(),
            dt.getMinuteOfHour(), dt.getSecondOfMinute());
}

From source file:de.pezeshki.bahaiCalendarLibrary.BadiDate.java

License:Apache License

/**
 * Creates a BadiDate from Joda DateTime.
 *
 * @param Joda//from ww w .  java  2 s  . c  om
 *            DateTime
 * @return The Badi date
 * @throws IllegalArgumentException
 *             Year is less than 1844 or greater than UPPER_YEAR_LIMIT
 */
public static BadiDate createFromDateTime(final BaseDateTime gregorianDate) throws IllegalArgumentException {
    final int year = gregorianDate.getYear();
    try {
        checkGregorianYearForValidity(year);
    } catch (final IllegalArgumentException e) {
        throw new IllegalArgumentException(e);
    }
    final int doy = gregorianDate.getDayOfYear();
    return createFromGregorianDoyAndYear(year, doy);
}

From source file:net.sourceforge.atunes.kernel.modules.tags.TagReader.java

License:Open Source License

private void validateDate(final ITag tag) {
    if (tag != null && tag.getDate() != null) {
        BaseDateTime date = tag.getDate();
        int year = date.getYear();
        int month = date.getMonthOfYear();
        int day = date.getDayOfMonth();
        boolean valid = true;
        if (year < 1000 || year > 9999) {
            valid = false;/* w  ww. j av a2s  .c o m*/
        }
        if (month < 1 || month > 12) {
            valid = false;
        }
        if (day < 1 || day > 31) {
            valid = false;
        }
        if (!valid) {
            tag.setDate(null);
        }
    }
}