Monday, 15 September 2014

java - How to add periods efficiently -



java - How to add periods efficiently -

i have timestamp t , find out timestamp t' @ origin of next period p after period t in, starting year 0.

example:

t = 2014-10-24t11:10:23.456z p = p1d t' 2014-10-25t00:00:00.000z

please note, p iso 8601 period.

my current implementation works (but extremely slow!):

period p = period.parse("p1m1d"); final mutabledatetime start= new mutabledatetime(starttimestamp); final mutabledatetime currentend = new mutabledatetime(0, 1, 1, 0, 0, 0, 0, datetimezone.utc); while (currentend.compareto(start) <= 0) { currentend.add(p); } system.out.println(currentend); --> 2014-11-02t00:00:00.000z

can think of more efficient way this?

java jodatime

No comments:

Post a Comment