java - Round DateTime by a given DateTimeFieldType -
i use org.joda.time.
i have datetime , datetimefieldtype given.
what want round datetime (up) nearest datetime after mine, integer number of given field.
for example:
for (datetime = 20/10/2013 14:20:31.200, datetimefiledtype = datetimefieldtype.dayofmonth()) i get: 21/10/2013 00:00:00.000.
did similar?
you can use:
datetime.now().dayofmonth().roundfloorcopy() or
datetime.now().dayofmonth().roundceilingcopy() take @ datetime.property class more information on this.
edit:
as krayo mentioned, can pass property directly as:
datetime.now().property(datetimefieldtype.secondofday()).roundfloorcopy();
Comments
Post a Comment