java dating - jsr 310 lightning talk
DESCRIPTION
A lightning talk that I presented to the London Java Community on JSR-310TRANSCRIPT
LJC/JCP CommitteeJava Dating
By James Gough
Thursday, 14 July 2011
LJC/JCP
• Who am I?
• What is the LJC/JCP?
• Why get involved?
Thursday, 14 July 2011
Who am I?• James Gough
• 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
3
Thursday, 14 July 2011
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
4
Thursday, 14 July 2011
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
5
Thursday, 14 July 2011
Dates?• The thing that's bothering me at the
moment is dating, there’s several things to be aware of:
• Choosing a good restaurant
• What to wear
• ....
6
Thursday, 14 July 2011
Java Dates
• Java Date and Calendar
• Joda Time
• JSR-310
7
Thursday, 14 July 2011
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
8
Thursday, 14 July 2011
Calendar
• Still mutable
• Can’t format a date directly
9
Thursday, 14 July 2011
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);
10
Thursday, 14 July 2011
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);
11
Thursday, 14 July 2011
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
12
Thursday, 14 July 2011
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");
13
Thursday, 14 July 2011
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!14
Thursday, 14 July 2011
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: [email protected]
15
Thursday, 14 July 2011
Contact• James Gough
• Twitter: goughjam
163
Thursday, 14 July 2011