java - Joda time, Period to total millis -
i'm trying total amount of milliseconds (not millis field) period object instance. i've tried multiple conversions, couldn't find method giving it.
has ever needed , managed retrieve ?
(i need patch, figure out negative period; negative millis = negative period.)
you can't millis directly period
, since fields months , years variable in terms of milliseconds.
in order make work, need supply "baseline" instant period
can calculate actual millisecond duration.
for example, period.todurationfrom
, period.todurationto
methods take such baseline instant, , calculate duration
object, can obtain millis.
the javadoc todurationfrom
says:
gets total millisecond duration of period relative start instant. method adds period specified instant in order calculate duration.
an instant must supplied duration of period varies. example, period of 1 month vary between equivalent of 28 , 31 days in milliseconds due different length months. similarly, day can vary @ daylight savings cutover, typically between 23 , 25 hours.
so need pick appropriate baseline instant application.
Comments
Post a Comment