Java Code Examples for org.joda.time.PeriodType#yearMonthDayTime()

The following examples show how to use org.joda.time.PeriodType#yearMonthDayTime() . 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: TestReadableDurationConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetInto_Object() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    ReadableDurationConverter.INSTANCE.setInto(m, new Duration(
        3L * DateTimeConstants.MILLIS_PER_DAY +
        4L * DateTimeConstants.MILLIS_PER_MINUTE + 5L
    ), null);
    assertEquals(0, m.getYears());
    assertEquals(0, m.getMonths());
    assertEquals(0, m.getWeeks());
    assertEquals(0, m.getDays());
    assertEquals(3 * 24, m.getHours());
    assertEquals(4, m.getMinutes());
    assertEquals(0, m.getSeconds());
    assertEquals(5, m.getMillis());
}
 
Example 2
Source File: TestStringConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetIntoPeriod_Object1() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    StringConverter.INSTANCE.setInto(m, "P2Y6M9DT12H24M48S", null);
    assertEquals(2, m.getYears());
    assertEquals(6, m.getMonths());
    assertEquals(9, m.getDays());
    assertEquals(12, m.getHours());
    assertEquals(24, m.getMinutes());
    assertEquals(48, m.getSeconds());
    assertEquals(0, m.getMillis());
}
 
Example 3
Source File: TestReadablePeriodConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetInto_Object() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    ReadablePeriodConverter.INSTANCE.setInto(m, new Period(0, 0, 0, 3, 0, 4, 0, 5), null);
    assertEquals(0, m.getYears());
    assertEquals(0, m.getMonths());
    assertEquals(0, m.getWeeks());
    assertEquals(3, m.getDays());
    assertEquals(0, m.getHours());
    assertEquals(4, m.getMinutes());
    assertEquals(0, m.getSeconds());
    assertEquals(5, m.getMillis());
}
 
Example 4
Source File: TestReadableDurationConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetInto_Object() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    ReadableDurationConverter.INSTANCE.setInto(m, new Duration(
        3L * DateTimeConstants.MILLIS_PER_DAY +
        4L * DateTimeConstants.MILLIS_PER_MINUTE + 5L
    ), null);
    assertEquals(0, m.getYears());
    assertEquals(0, m.getMonths());
    assertEquals(0, m.getWeeks());
    assertEquals(0, m.getDays());
    assertEquals(3 * 24, m.getHours());
    assertEquals(4, m.getMinutes());
    assertEquals(0, m.getSeconds());
    assertEquals(5, m.getMillis());
}
 
Example 5
Source File: TestStringConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetIntoPeriod_Object1() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    StringConverter.INSTANCE.setInto(m, "P2Y6M9DT12H24M48S", null);
    assertEquals(2, m.getYears());
    assertEquals(6, m.getMonths());
    assertEquals(9, m.getDays());
    assertEquals(12, m.getHours());
    assertEquals(24, m.getMinutes());
    assertEquals(48, m.getSeconds());
    assertEquals(0, m.getMillis());
}
 
Example 6
Source File: TestReadablePeriodConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testSetInto_Object() throws Exception {
    MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
    ReadablePeriodConverter.INSTANCE.setInto(m, new Period(0, 0, 0, 3, 0, 4, 0, 5), null);
    assertEquals(0, m.getYears());
    assertEquals(0, m.getMonths());
    assertEquals(0, m.getWeeks());
    assertEquals(3, m.getDays());
    assertEquals(0, m.getHours());
    assertEquals(4, m.getMinutes());
    assertEquals(0, m.getSeconds());
    assertEquals(5, m.getMillis());
}
 
Example 7
Source File: DateUtils.java    From restcommander with Apache License 2.0 2 votes vote down vote up
/**
 * Returns time difference
 * 
 * @param d1
 * @param d2
 * @return
 */
public static String getDateDifference(Date d1, Date d2) {
	Period period = new Period(new DateTime(d1), new DateTime(d2),
			PeriodType.yearMonthDayTime());
	return PERIOD_FORMATTER.print(period);
}