Java Code Examples for org.joda.time.Period#toStandardSeconds()
The following examples show how to use
org.joda.time.Period#toStandardSeconds() .
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: TestUserProfileUtils.java From Eagle with Apache License 2.0 | 6 votes |
@Test public void testFormatSecondsByPeriod15M() throws ParseException { Period period = new Period("PT15m"); Seconds seconds = period.toStandardSeconds(); Assert.assertEquals(15*60,seconds.getSeconds()); long time = DateTimeUtil.humanDateToSeconds("2015-07-01 13:56:12"); long expect = DateTimeUtil.humanDateToSeconds("2015-07-01 13:45:00"); long result = UserProfileUtils.formatSecondsByPeriod(time,seconds); Assert.assertEquals(expect,result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = UserProfileUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect,result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = UserProfileUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect,result); }
Example 2
Source File: TestUserProfileUtils.java From Eagle with Apache License 2.0 | 6 votes |
@Test public void testFormatSecondsByPeriod1H() throws ParseException { Period period = new Period("PT1h"); Seconds seconds = period.toStandardSeconds(); Assert.assertEquals(60*60,seconds.getSeconds()); long time = DateTimeUtil.humanDateToSeconds("2015-07-01 13:56:12"); long expect = DateTimeUtil.humanDateToSeconds("2015-07-01 13:00:00"); long result = UserProfileUtils.formatSecondsByPeriod(time,seconds); Assert.assertEquals(expect,result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = UserProfileUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect,result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:30:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = UserProfileUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect,result); }
Example 3
Source File: TimePeriodUtilsTest.java From eagle with Apache License 2.0 | 6 votes |
@Test public void testFormatSecondsByPeriod15M() throws ParseException { Period period = new Period("PT15m"); Seconds seconds = period.toStandardSeconds(); Assert.assertEquals(15 * 60, seconds.getSeconds()); long time = DateTimeUtil.humanDateToSeconds("2015-07-01 13:56:12"); long expect = DateTimeUtil.humanDateToSeconds("2015-07-01 13:45:00"); long result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); }
Example 4
Source File: TimePeriodUtilsTest.java From eagle with Apache License 2.0 | 6 votes |
@Test public void testFormatSecondsByPeriod1H() throws ParseException { Period period = new Period("PT1h"); Seconds seconds = period.toStandardSeconds(); Assert.assertEquals(60 * 60, seconds.getSeconds()); long time = DateTimeUtil.humanDateToSeconds("2015-07-01 13:56:12"); long expect = DateTimeUtil.humanDateToSeconds("2015-07-01 13:00:00"); long result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:14:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); time = DateTimeUtil.humanDateToSeconds("2015-07-01 03:30:59"); expect = DateTimeUtil.humanDateToSeconds("2015-07-01 03:00:00"); result = TimePeriodUtils.formatSecondsByPeriod(time, seconds); Assert.assertEquals(expect, result); }
Example 5
Source File: Utils.java From UTubeTV with The Unlicense | 4 votes |
public static String durationToDuration(String isoDuration) { Period p = mFormatter.parsePeriod(isoDuration); Seconds s = p.toStandardSeconds(); return millisecondsToDuration(s.getSeconds() * 1000); }