Java Code Examples for org.joda.time.Chronology#getDateTimeMillis()

The following examples show how to use org.joda.time.Chronology#getDateTimeMillis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 1_BasicChronology.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
Example 2
Source File: BasicChronology.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
Example 3
Source File: GJChronology.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int millisOfDay)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    // Assume date is Gregorian.
    long instant = iGregorianChronology.getDateTimeMillis
        (year, monthOfYear, dayOfMonth, millisOfDay);
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth, millisOfDay);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}
 
Example 4
Source File: Time_18_GJChronology_s.java    From coming with MIT License 6 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int millisOfDay)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    // Assume date is Gregorian.
    long instant = iGregorianChronology.getDateTimeMillis
        (year, monthOfYear, dayOfMonth, millisOfDay);
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth, millisOfDay);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}
 
Example 5
Source File: Time_18_GJChronology_t.java    From coming with MIT License 6 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int millisOfDay)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    // Assume date is Gregorian.
    long instant = iGregorianChronology.getDateTimeMillis
        (year, monthOfYear, dayOfMonth, millisOfDay);
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth, millisOfDay);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}
 
Example 6
Source File: Nopol2017_0088_t.java    From coming with MIT License 6 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
Example 7
Source File: Nopol2017_0088_s.java    From coming with MIT License 6 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
Example 8
Source File: Time_18_GJChronology_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Convert a datetime from one chronology to another.
 */
private static long convertByYear(long instant, Chronology from, Chronology to) {
    return to.getDateTimeMillis
        (from.year().get(instant),
         from.monthOfYear().get(instant),
         from.dayOfMonth().get(instant),
         from.millisOfDay().get(instant));
}
 
Example 9
Source File: AssembledChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(long instant,
                              int hourOfDay, int minuteOfHour,
                              int secondOfMinute, int millisOfSecond)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = iBase) != null && (iBaseFlags & 1) == 1) {
        // Only call specialized implementation if applicable fields are the same.
        return base.getDateTimeMillis
            (instant, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }
    return super.getDateTimeMillis
        (instant, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
}
 
Example 10
Source File: GJChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert a datetime from one chronology to another.
 */
private static long convertByYear(long instant, Chronology from, Chronology to) {
    return to.getDateTimeMillis
        (from.year().get(instant),
         from.monthOfYear().get(instant),
         from.dayOfMonth().get(instant),
         from.millisOfDay().get(instant));
}
 
Example 11
Source File: Time_18_GJChronology_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Convert a datetime from one chronology to another.
 */
private static long convertByYear(long instant, Chronology from, Chronology to) {
    return to.getDateTimeMillis
        (from.year().get(instant),
         from.monthOfYear().get(instant),
         from.dayOfMonth().get(instant),
         from.millisOfDay().get(instant));
}
 
Example 12
Source File: AssembledChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int hourOfDay, int minuteOfHour,
                              int secondOfMinute, int millisOfSecond)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = iBase) != null && (iBaseFlags & 5) == 5) {
        // Only call specialized implementation if applicable fields are the same.
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }
    return super.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                   hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
}
 
Example 13
Source File: Time_6_GJChronology_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Convert a datetime from one chronology to another.
 */
private static long convertByYear(long instant, Chronology from, Chronology to) {
    return to.getDateTimeMillis
        (from.year().get(instant),
         from.monthOfYear().get(instant),
         from.dayOfMonth().get(instant),
         from.millisOfDay().get(instant));
}
 
Example 14
Source File: BasicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth, int millisOfDay)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    FieldUtils.verifyValueBounds
        (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY - 1);
    return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay;
}
 
Example 15
Source File: Time_6_GJChronology_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Convert a datetime from one chronology to another.
 */
private static long convertByYear(long instant, Chronology from, Chronology to) {
    return to.getDateTimeMillis
        (from.year().get(instant),
         from.monthOfYear().get(instant),
         from.dayOfMonth().get(instant),
         from.millisOfDay().get(instant));
}
 
Example 16
Source File: 1_BasicChronology.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth, int millisOfDay)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    FieldUtils.verifyValueBounds
        (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY);
    return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay;
}
 
Example 17
Source File: AssembledChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int millisOfDay)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = iBase) != null && (iBaseFlags & 6) == 6) {
        // Only call specialized implementation if applicable fields are the same.
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }
    return super.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
}
 
Example 18
Source File: AssembledChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int hourOfDay, int minuteOfHour,
                              int secondOfMinute, int millisOfSecond)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = iBase) != null && (iBaseFlags & 5) == 5) {
        // Only call specialized implementation if applicable fields are the same.
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }
    return super.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                   hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
}
 
Example 19
Source File: Time_6_GJChronology_s.java    From coming with MIT License 4 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int hourOfDay, int minuteOfHour,
                              int secondOfMinute, int millisOfSecond)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    // Assume date is Gregorian.
    long instant;
    try {
        instant = iGregorianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    } catch (IllegalFieldValueException ex) {
        if (monthOfYear != 2 || dayOfMonth != 29) {
            throw ex;
        }
        instant = iGregorianChronology.getDateTimeMillis
            (year, monthOfYear, 28,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
        if (instant >= iCutoverMillis) {
            throw ex;
        }
    }
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}
 
Example 20
Source File: Time_6_GJChronology_t.java    From coming with MIT License 4 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int hourOfDay, int minuteOfHour,
                              int secondOfMinute, int millisOfSecond)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    // Assume date is Gregorian.
    long instant;
    try {
        instant = iGregorianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    } catch (IllegalFieldValueException ex) {
        if (monthOfYear != 2 || dayOfMonth != 29) {
            throw ex;
        }
        instant = iGregorianChronology.getDateTimeMillis
            (year, monthOfYear, 28,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
        if (instant >= iCutoverMillis) {
            throw ex;
        }
    }
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth,
             hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}