Example usage for org.joda.time Period getValue

List of usage examples for org.joda.time Period getValue

Introduction

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

Prototype

public int getValue(int index) 

Source Link

Document

Gets the value at the specified index.

Usage

From source file:com.facebook.presto.jdbc.ext.PrestoResultSet.java

License:Apache License

private PrestoIntervalYearMonth getIntervalYearMonth(int columnIndex) throws SQLException {
    Object value = column(columnIndex);
    if (value == null) {
        return null;
    }/*from   w w  w  .ja v a 2 s .c o  m*/

    Period period = INTERVAL_YEAR_TO_MONTH_FORMATTER.parsePeriod(String.valueOf(value));
    return new PrestoIntervalYearMonth(period.getValue(YEAR_FIELD), period.getValue(MONTH_FIELD));
}

From source file:com.facebook.presto.jdbc.ext.PrestoResultSet.java

License:Apache License

private PrestoIntervalDayTime getIntervalDayTime(int columnIndex) throws SQLException {
    Object value = column(columnIndex);
    if (value == null) {
        return null;
    }//from w  w  w . j  ava2 s.  com

    Period period = INTERVAL_DAY_TO_SECOND_FORMATTER.parsePeriod(String.valueOf(value));
    return new PrestoIntervalDayTime(period.getValue(DAY_FIELD), period.getValue(HOUR_FIELD),
            period.getValue(MINUTE_FIELD), period.getValue(SECOND_FIELD), period.getValue(MILLIS_FIELD));
}

From source file:com.facebook.presto.util.DateTimeUtils.java

License:Apache License

public static long parsePeriodMillis(PeriodFormatter periodFormatter, String value, IntervalField startField,
        IntervalField endField) {/*w  w w . ja  va2 s . c  o  m*/
    Period period = parsePeriod(periodFormatter, value, startField, endField);
    return SqlIntervalDayTime.toMillis(period.getValue(DAY_FIELD), period.getValue(HOUR_FIELD),
            period.getValue(MINUTE_FIELD), period.getValue(SECOND_FIELD), period.getValue(MILLIS_FIELD));
}

From source file:com.facebook.presto.util.DateTimeUtils.java

License:Apache License

private static long parsePeriodMonths(String value, PeriodFormatter periodFormatter, IntervalField startField,
        IntervalField endField) {/*  w  w  w  . j a  va 2 s  . co  m*/
    Period period = parsePeriod(periodFormatter, value, startField, endField);
    return period.getValue(YEAR_FIELD) * 12 + period.getValue(MONTH_FIELD);
}

From source file:com.the.todo.task.ReminderTask.java

License:MIT License

public ReminderTask(ToDo todo, LocalDateTime currentDateTime) {
    Period p = new Period(currentDateTime, todo.getEndDate(), PeriodType.seconds());

    timer = new Timer();
    timer.schedule(new ToDoReminder(todo), p.getValue(0) * 1000);
}

From source file:io.prestosql.util.DateTimeUtils.java

License:Apache License

public static long parsePeriodMillis(PeriodFormatter periodFormatter, String value, IntervalField startField,
        IntervalField endField) {//from ww  w  . java 2s .co  m
    try {
        Period period = parsePeriod(periodFormatter, value);
        return IntervalDayTime.toMillis(period.getValue(DAY_FIELD), period.getValue(HOUR_FIELD),
                period.getValue(MINUTE_FIELD), period.getValue(SECOND_FIELD), period.getValue(MILLIS_FIELD));
    } catch (IllegalArgumentException e) {
        throw invalidInterval(e, value, startField, endField);
    }
}

From source file:io.prestosql.util.DateTimeUtils.java

License:Apache License

private static long parsePeriodMonths(String value, PeriodFormatter periodFormatter, IntervalField startField,
        IntervalField endField) {/*from  ww  w.  j  av a 2s . c om*/
    try {
        Period period = parsePeriod(periodFormatter, value);
        return IntervalYearMonth.toMonths(period.getValue(YEAR_FIELD), period.getValue(MONTH_FIELD));
    } catch (IllegalArgumentException e) {
        throw invalidInterval(e, value, startField, endField);
    }
}