mirror of https://github.com/apache/jclouds.git
Issue 97: added function to derive date from seconds since epoch
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1930 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
98ad5128df
commit
09b2c80cd2
|
@ -77,6 +77,10 @@ public class DateService {
|
|||
rfc822SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
|
||||
}
|
||||
|
||||
public final DateTime fromSeconds(long seconds) {
|
||||
return new DateTime(seconds*1000);
|
||||
}
|
||||
|
||||
public final String rfc822DateFormat(DateTime dateTime) {
|
||||
return rfc822DateTimeFormatter.print(dateTime);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.List;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.jclouds.PerformanceTest;
|
||||
import org.jclouds.util.DateService;
|
||||
import org.joda.time.DateTime;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -113,6 +112,13 @@ public class DateServiceTest extends PerformanceTest {
|
|||
dateService.iso8601DateFormat();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFromSeconds() throws ExecutionException, InterruptedException {
|
||||
long seconds = 1254008225;
|
||||
DateTime date = dateService.fromSeconds(seconds);
|
||||
assertEquals(dateService.rfc822DateFormat(date), "Sat, 26 Sep 2009 23:37:05 GMT");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRfc822DateFormatResponseTime() throws ExecutionException, InterruptedException {
|
||||
for (int i = 0; i < LOOP_COUNT; i++)
|
||||
|
|
Loading…
Reference in New Issue