Java may get time, date upgrade

Connect with state & local government leaders
 

Connecting state and local government leaders

A number of developers are working on new time and date interfaces for the Java programming language.

A number of developers are working on new time and date
interfaces for the Java programming language.


At the JavaOne 2008 Conference last month, Stephen Colebourne,
an architect at Switzerland-based integrator Sita, and Michael
Santos, a senior technical consultant at Summa Technologies,
presented their work on the Java
Specification Request (JSR) 310 ' Date and Time Application
Programming Interface (API).


Although Java has a class to define dates and another class to
define time, both have a number of
shortcomings, the developers said. The new API will allow
developers to work with dates and time with far more flexibility,
they added.


The API will offer developers two broad definitions of time: One
is continuous time or machine time, and the other is human
time.


For continuous time, the API will include a way to record an
instant of time, which would be captured as so many units after a
predefined epoch. The base is a single number representing some
point in time, as referenced from some earlier predefined point in
time.


In continuous time, two instances could be used to create an
interval ' or the set of all instances that lie between the
start and end times. The instances could also be used to create a
duration ' namely, the length of time between two events.


"You will be able to build an instance [that records] a number
of seconds or a number of nanoseconds," Santos said. "You will also
be able to compare instances to see if one happens before or after
the other. Or you can check to see if an instant appears within an
interval."


The second kind of time the API supports ' human time
' breaks time into a number of recognizable fields, such as
the year, month, hour, minute and second. For human time, the API
will adopt ISO standard 8601.


In this standard, dates are represented in the yyyy-mm-dd
format. Accordingly, June 3, 2008, would be represented as
2008-06-03. The time of day would be represented in the hh:mm:ss
format; thus, 9:15 a.m. Eastern Time would be represented as
09:15:00. ISO 8601 also offers an annotation for specifying the
offset of this time from Universal Coordinated Time.


In addition, JSR 310 will also include features to help resolve
some of the trickier problems programmers face when devising
calculations involving dates and time.


A feature known as a resolver can, when given an incorrect date
(e.g., Feb. 30), adjust it to the correct date (March 1 or March 2
depending on whether it is a leap year). Another feature, called an
adjuster, can calculate a date when given a set of conditions. For
instance, it can allow a program to ask what the last day of any
given month is.


Another feature adjusts the timestamps that might have gotten
botched by Daylight Saving Time rules, which can help parse those
periods of time in which events in two separate hours are recorded
as happening in the same hour due to clocks being set back an
hour.


Colebourne said the development team is also planning to make
the API extensible because "there are many ways to manipulate
time." For instance, some organizations pay employees every other
week, while others pay their people twice a month. Making the API
extensible ensures that each organization can manipulate their time
data in ways that are specific to their organizations.


Another example of extensibility is the calendaring system. By
default, the API will use the Gregorian calendar system. However,
other calendars could be entered as separate date classes. Examples
include the Hebrew calendar, the Japanese calendar and historic
calendars such as the Julian calendar.


"If you know the particular calendar system you want to deal
with, then you have a date object that represents just that
particular calendar system," Colebourne said.


A JSR is a proposed specification for extending the Java
programming language. It could be integrated with the current
date/time classes because the keepers of the Java language have no
plans to deprecate those classes. The Java Community Process
program, which manages Java, has made no decision on including JSR
310 in Java 7, the next version of the programming language. The
developers are seeking other volunteers to help further define the
specification.


"We want to make sure this JSR works," Colebourne said.
'We can't afford a third broken date-and-time API.'



X
This website uses cookies to enhance user experience and to analyze performance and traffic on our website. We also share information about your use of our site with our social media, advertising and analytics partners. Learn More / Do Not Sell My Personal Information
Accept Cookies
X
Cookie Preferences Cookie List

Do Not Sell My Personal Information

When you visit our website, we store cookies on your browser to collect information. The information collected might relate to you, your preferences or your device, and is mostly used to make the site work as you expect it to and to provide a more personalized web experience. However, you can choose not to allow certain types of cookies, which may impact your experience of the site and the services we are able to offer. Click on the different category headings to find out more and change our default settings according to your preference. You cannot opt-out of our First Party Strictly Necessary Cookies as they are deployed in order to ensure the proper functioning of our website (such as prompting the cookie banner and remembering your settings, to log into your account, to redirect you when you log out, etc.). For more information about the First and Third Party Cookies used please follow this link.

Allow All Cookies

Manage Consent Preferences

Strictly Necessary Cookies - Always Active

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data, Targeting & Social Media Cookies

Under the California Consumer Privacy Act, you have the right to opt-out of the sale of your personal information to third parties. These cookies collect information for analytics and to personalize your experience with targeted ads. You may exercise your right to opt out of the sale of personal information by using this toggle switch. If you opt out we will not be able to offer you personalised ads and will not hand over your personal information to any third parties. Additionally, you may contact our legal department for further clarification about your rights as a California consumer by using this Exercise My Rights link

If you have enabled privacy controls on your browser (such as a plugin), we have to take that as a valid request to opt-out. Therefore we would not be able to track your activity through the web. This may affect our ability to personalize ads according to your preferences.

Targeting cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.

Social media cookies are set by a range of social media services that we have added to the site to enable you to share our content with your friends and networks. They are capable of tracking your browser across other sites and building up a profile of your interests. This may impact the content and messages you see on other websites you visit. If you do not allow these cookies you may not be able to use or see these sharing tools.

If you want to opt out of all of our lead reports and lists, please submit a privacy request at our Do Not Sell page.

Save Settings
Cookie Preferences Cookie List

Cookie List

A cookie is a small piece of data (text file) that a website – when visited by a user – asks your browser to store on your device in order to remember information about you, such as your language preference or login information. Those cookies are set by us and called first-party cookies. We also use third-party cookies – which are cookies from a domain different than the domain of the website you are visiting – for our advertising and marketing efforts. More specifically, we use cookies and other tracking technologies for the following purposes:

Strictly Necessary Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Functional Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Performance Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Social Media Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Targeting Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.