Joda Time's LocalDate
describe itself as:
LocalDate is an immutable datetime class representing a date without a time zone.
Yet there is a LocalDate(Object instant, DateTimeZone zone)
constructor that accepts time zone. If the object is time zone-less, what's the purpose of the time zone constructor?
The constructor JavaDocs states:
Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.
I don't know what is meant by "forcing the time zone to that specified", since the object is time zone-less. Perhaps it internally converts to UTC, then drops the time (keeps the date).
Joda-Time is the most widely used date and time processing library, before the release of Java 8. Its purpose was to offer an intuitive API for processing date and time and also address the design issues that existed in the Java Date/Time API.
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. However, all date fields may in fact be queried.
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.
An instant is a concept from the realm of physics. It's a point in time, well defined, regardless of how you represent it. It's has nothing to do -conceptually- with timezones, calendars, or whatever conventions of human culture.
Examples: the moment when the Apollo XI landed on Moon, or the moment when J. Kennedy was shot, are instants. Each of these could be represented in several ways: a Julian calendar, seconds lapsed from the moment when the Titanic hit the iceberg, some calendar used by some extraterrestial being who lives in Mars... all these would be different representations, but the instant would be a single one (just like 1903
, 0x76F
or MCMIII
are different representations of the same number).
Now, if you want to convert the "instant of Apollo XI moon landing" to a LocalDate (a day-month-year, as used in Gregorian calendars in Earth), you are going to a totally different realm, and -for one thing- you need to know the timezone, because in some countries that instant (July 20, 1969, 20:17:40 UTC) corresponds to July 20, 1969, in others to July 21
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