jodatime.tex 1.9 KB

12345678910111213141516171819202122232425262728
  1. \section{Joda Time}
  2. Joda Time~\cite{jodatime} is a Java date and time API.
  3. It provides a quality replacement for the Java date and time classes.
  4. %We used this API because the Java Date and Calendar classes are badly designed.
  5. \salespoint{} incorporates Joda Time, because it is open source, easy to use and offers better performance characteristics than Java date and time classes.
  6. Key concepts from Joda Time used in \salespoint{} are \textit{Instant}, \textit{Interval}, \textit{Duration} and \textit{Period}.
  7. Instant is explained in the Joda Time documentation as follows:
  8. \begin{quote}
  9. The most frequently used concept in Joda-Time is that of the \textit{instant}.
  10. An Instant is defined as \textit{an instant in the datetime continuum specified as a number of milliseconds from 1970-01-01T00:00Z}.
  11. This definition of milliseconds is consistent with that of the JDK in \code{Date} or \code{Calendar}.
  12. Interoperating between the two APIs is thus simple.
  13. \end{quote}
  14. An \textit{Interval} is defined by two Instants, the start and the end.
  15. An Interval is \textit{half-open}, that is to say the start is inclusive but the end is not.
  16. The end is always greater or equal than the start.
  17. A \textit{Duration} in Joda Time represents a duration in time, exact to the milisecond.
  18. Durations can be thought of as length of an Interval.
  19. A Duration does not have a start and an end, but is rather the difference $end - start$.
  20. A \textit{Period} also represents a duration in time, but in a more abstract way.
  21. A Period may be a month, which may have 28, 29, 30 or 31 days. The absolute length in miliseconds of those periods differ.
  22. If you, for example have an Instant of February, 1st and add a Period of one month, the result will be an Instant of March, 1st.
  23. Adding instead a Period of 30 days to an Instant of February, 1st will result in an Instant of March, 2nd or March 3rd, depending if the Instant is in a leap year or not.