I wanted to convert joda time LocalTime to millis or milliseconds. I saw that the getLocalMillis is a protected method. Looks like there is no method to get the millis value of LocalTime.
So, do I have to get the values of each field in millis and then add them up to get the total millis ? Why does Joda Time not have a public method for getting Local Millis ?
So the short answer to your question is: YES (deprecated).
An interval in Joda-Time represents an interval of time from one instant to another instant. Both instants are fully specified instants in the datetime continuum, complete with time zone.
Joda-Time is an API created by joda.org which offers better classes and having efficient methods to handle date and time than classes from java. util package like Calendar, Gregorian Calendar, Date, etc. This API is included in Java 8.0 with the java.
LocalDate is an immutable datetime class representing a date without a time zone. LocalDate implements the ReadablePartial interface. To do this, the interface methods focus on the key fields - Year, MonthOfYear and DayOfMonth.
A LocalTime
does not represent an absolute instant in time, but rather it describes a time of any day for an arbitrary timezone.
Render your LocalTime
into an DateTime
via LocalTime#toDateTimeToday()
or LocalTime#toDateTimeToday(DateTimeZone)
if you're looking for the moment described by that time today. Or if you want that moment on another day, construct the appropriate LocalDate
and see the LocalDate#toDateTime(...)
methods. Then call DateTime#getMillis()
.
You can use also .toDate().getTime()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With