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:
adrian.f.cole 2009-09-27 18:22:32 +00:00
parent 98ad5128df
commit 09b2c80cd2
2 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -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++)