Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Java Dating - JSR 310 Lightning Talk

1,055 views

Published on

A lightning talk that I presented to the London Java Community on JSR-310

Published in: Technology, News & Politics
  • Be the first to comment

Java Dating - JSR 310 Lightning Talk

  1. 1. LJC/JCP Committee Java Dating By James GoughThursday, 14 July 2011
  2. 2. LJC/JCP • Who am I? • What is the LJC/JCP? • Why get involved?Thursday, 14 July 2011
  3. 3. Who am I? • James Gough • jpgough@gmail.com • Twitter: goughjam • Java developer for 8 years, 4 years industry experience • Work at a large investment bank developing Flex and Java • Run my own company in spare time developing iOS applications 3Thursday, 14 July 2011
  4. 4. LJC/JCP • LJC recently elected onto the JCP committee • JCP (Java Community Process) • The JCP is the mechanism for developing standard technical specifications for the Java technology • Interested? Ben Evans @kittylst on twitter, or find me at the bar on Tuesday 4Thursday, 14 July 2011
  5. 5. Why get involved? • Chance to have a say • Discover more about Java and the inner workings • Get involved on projects and contribute to Java directly • Offered to do a lightning talk • Coming soon: Java memory pub 5Thursday, 14 July 2011
  6. 6. Dates? • The thing thats bothering me at the moment is dating, there’s several things to be aware of: • Choosing a good restaurant • What to wear • .... 6Thursday, 14 July 2011
  7. 7. Java Dates • Java Date and Calendar • Joda Time • JSR-310 7Thursday, 14 July 2011
  8. 8. Java Date • Java Date has been in the language since January 23, 1996 • Many good discussions about what’s wrong with dates • Mutability • Date is a DateTime, but there are other classes for SQL • No Timezones • Not easy to use 8Thursday, 14 July 2011
  9. 9. Calendar • Still mutable • Can’t format a date directly 9Thursday, 14 July 2011
  10. 10. Example From It’s High Time @JavaOne 2008 • How many bugs in this code? Date date = new Date(2007, 12, 13, 16, 40); TimeZone zone = TimeZone.getInstance ("Asia/HongKong"); Calendar cal = new GregorianCalendar (date, zone); DateFormat fm = new SimpleDateFormat ("HH:mm Z"); String str = fm.format(cal); 10Thursday, 14 July 2011
  11. 11. Example From It’s High Time @JavaOne 2008 • 6 bugs in the code! Date date = new Date(2007, 12, 13, 16, 40); TimeZone zone = TimeZone.getInstance ("Asia/Hong_Kong"); Calendar cal = new GregorianCalendar (date, zone); DateFormat fm = new SimpleDateFormat ("HH:mm Z"); String str = fm.format(cal); 11Thursday, 14 July 2011
  12. 12. Joda Time • Instant • Moment in time, represented by DateTime. DateTime is immutable • Interval • An interval of time from one instant to another. Both end points have same Chronology and TimeZone • Duration • Duration of time measured in milliseconds. No timezone of chronology applies 12Thursday, 14 July 2011
  13. 13. Joda Time • Period • A period of time defined in terms of fields (e.g. +1 month) • Chronology • A calculation engine supporting complex calendar rules • In most this can be ignored, important to the internal design, but not to the standard user using ISOChronology • Timezones • DateTimeZone zone = DateTimeZone.forID ("Europe/London"); 13Thursday, 14 July 2011
  14. 14. JSR-310 • Human/Machine Timelines • Requirement to have a separation of concerns between human and machine timelines • DateTime is better thought of as a LocalDateTime and a timezone • Pluggable Chronology • Restrict DateTime classes to a single calendar system • Nulls • Null means 0 in most cases, ouch! 14Thursday, 14 July 2011
  15. 15. Getting Involved • ThreeTen is now on GitHub • Open project that can be contributed to • A few pull requests have been made since moving to GitHub • Accept the legal agreement • Mailing List: threeten- develop@lists.sourceforge.net 15Thursday, 14 July 2011
  16. 16. Contact • James Gough • jpgough@gmail.com • Twitter: goughjam 3 16Thursday, 14 July 2011

×