This page is designed for all members of the Java community to add requests to the project/JSR-310. All ideas are welcome.
Additions may be made using your signature, or anonymously.
A bit of an edge case, but IMHO the text parser should be able to handle the three kinds of HTTP/1.1 dateformat as HTTP is likely to stick around for awhile. Quoting RFC 2616, section 3.3:
- RFC 822, updated by RFC 1123
* Sunday, 06-Nov-94 08:49:37 GMT
- RFC 850, obsoleted by RFC 1036
* Sun Nov 6 08:49:37 1994
- ANSI C's asctime() format
The first two formats are no problem, but the third format prefixes single-digit days with a space rather than a zero to preserve fixed length. This is an uncommon bit of markup that tends to require special attention.
-- BarendGarvelink - 05 Mar 2007
At present Java has its own method for determining timezones.
This means that any changes have to be applied to both the OS and Java. Also discrepancies can creep in.
If the OS supports TZ information, then it seems to me that Java should use the OS view.
-- Main.sebbazgm - 10 Mar 2007
Currently, time representation in Java is limited to a simplified UTC model and location based timezones. For some scientific applications, this is wrong since leap seconds are ignored and this is also insufficient. An example of wrong behaviour is that the interval between 2005-12-31T23:59:00 and 2006-01-01T00:01:00 was 121 seconds long, not 120 seconds long). There is currently no way to consider the TAI (International Atomic Time), TT (Terrestrial Time), nor GPS time. I don't consider more complex scales such as Geocentric Coordinate Time (TCG) or Barycentric Coordinate Time (TCB) because they are not computed by simple offsets as the previous ones.
Supporting this could be done very simply by providing additional timezones (TAI, TT, GPS and leap-seconds-corrected-UTC). Since most users don't need these refinements, they could simply ignore these timezones they do not know and everything would be backward compatible. These timezones would be helpful for high accuracy and scientific work (space dynamics, oceanography, geodesy, navigation ...) , as well as for embedded devices relying on either GPS, Glonass or Galileo signals or NTP.
The only time dependant offset is the one between TAI and UTC, which changes each time a leap second is introduced. Leap seconds are not introduced very often as the http://hpiers.obspm.fr/eoppc/bul/bulc/UTC-TAI.history...[official history file] from IERS shows. It would probably be sufficient to consider only the integer offsets starting 1972-01-01. It is also guaranteed that the changes are known several months in advance.
-- Main.luc - 12 Mar 2007
I think this is a good suggestion. -- BarendGarvelink
pls consideer an APi to get the first day of week of a selected date, I need ot for making the week view of a calendar, suppose today is "wednesday" i should be able to get the date of the first day of the week that is sunday.
-- daljeetsingh
This is part of a suite of geospatial standards, but this one only deals with time, and presents only a data model. Interfaces for a portion of this model are defined within the GeoAPI project (http://geoapi.sourceforge.net/pending/javadoc/org/opengis/temporal/package-summary.html), which could either be leveraged directly or used as a guideline.
This is a considerably more flexible model than "dates" and "calandars". You can define a temporal reference frame to describe the following types of situations:
This specification has temporal geometry (e.g. "points" and "intervals") as well as a way to express temporal topography (e.g. temporal relations: Things B,C and D succeed/replace thing A.)
Last but not least, this is not just a specification, it's an international standard. Unfortunately, this means that developers on this JSR should probably buy it. Fortunately, it's only $30 US. A quality interface implementation with good javadocs should obviate any need for the average Java developer to buy it.
-- Main.bnordgren - 13 Mar 2007
Different domains and even different problems within a single domain require time points of different granularity. Many things happen at day precision and for many business purposes anything more fine-grained than second precision just does not make any sense. For more technical purposes, I might want millisecond precision or even better.
Fowler has written this up more eloquently than I possibly could: http://www.martinfowler.com/ap2/timePoint.html
Please note that I am explicitly referring to time points, not intervals or periods.
Thanks, Oliver
-- Main.okamps - 24 May 2007
+1. I work in a scientific domain where time events (Instants?) have to be compared with each other. Equipment taking physical timestamped measurements have variable time precision (seconds, millis, nanos) and this has to be taken into account when making comparisons.
-- NiallStapley
As mentioned on the mailing list, it would be cool to be able to simply create a DateTime from an existing DateTime plus / minus a Duration - good for getting birth dates for people of a certain age among other things.
It would also be useful to be able to do the following:
TimeOfDay now = TimeOfDay.currentTime(); then = now.minusMinutes(10); Duration d = now.minus(then);
Thanks, Andrew
-- Main.al94781 - 04 Jun 2007
I think it will be useful if we are able to find out the difference between two date/time objects. Off my head, I can think of one use case: finding out the number of days that has elapsed to compute late-return charges.
Of course, the api should allow us to define the (reasonable) period to compute the difference. For example, using hypothetical api calls, and liberal variable names:
date1.hasSinceElapsed(Days, fromDate); date1.hasSinceElapsed(Hours, fromDate); time1.hasSinceElapsed(Seconds, fromTime);
Thanks, shaolang
For example, what is 7/31-1m1d? In Jode, it's computed as 7/31-1m-1d=6/30-1d=6/29. However, I think the proper answer should be 6/30.
Thanks, Weijun
An API user must not be able to generate a reference to Today without specifying the TimeZone that they're in. The assumption is that we're using the default TimeZone of the user. However, unless this is made clear to the user, mistakes will creep in.
I would suggest as the method signature: CalendarDay.today(TimeZone timeZone)
Then, you could add an additional method of today() with Javadoc to explicitly state "this version of today() uses TimeZone.getDefaultTimeZone() to generate today's date. Please use with caution."
-- Main.daveboden - 08 Aug 2007
The getDayOfWeek() method should return an enum rather than an int value. The fact that the day of the week is stored as an integer is an implementation detail. The numbering is arbitrary. Someone is going to do a > b on the day of week values if you give them the opportunity to. This boolean statement is pretty much meaningless, what's the programmer trying to do? Giving programmers an enum is more meaningful: Sunday rather than "1".
-- Main.daveboden - 13 Aug 2007
Setting the JVM's clock (not OS's clock) with a choice of either:
Granted the these requests might be out of the scope of this project, I thought I'd throw them out there for discussion.
-- Main.pdjohe - 09 Sep 2007
As many have already mentioned, this project should definitely work hand-in-hand with Units API being defined in JSR-275. Both groups should decide together where basic time duration units (nanosecond, millisecond, second, minute, hour, etc. - see http://en.wikipedia.org/wiki/Category:Units_of_time ) should be defined. There is no need for a both a javax.time.Second and a javax.measure.unit.NonSI.Second class to spring up at the same time in JSE7. Somebody from the expert JSR-310 group should be on the expert group of JRS-275 and visa versa. I'm sure both groups have some similar goals for time and dates and their calculations. And any functionality designed in JRS-275 could simplify work in JSR-310. For example, if JRS-275 is based on JScience and has something like http://jscience.org/api/javax/measure/unit/NonSI.html for units and http://jscience.org/api/org/jscience/mathematics/number/Rational.html for fractions, then some of the proposed unit classes and the Fraction class (https://jsr-310.dev.java.net/nonav/generics/javax/math/Fraction.html) might be unneeded in this project.
-- Main.pdjohe - 09 Sep 2007
[These comments refer to the closed Generics branch, rather than the active Trunk] - most of these points are addressed there - scolebourne]
Not trying to be overly critical (I would like to sound more positive) but I see ZERO benefit of this API at this point. Why would you clutter up the JDK with something this inaccurate, unperformant, illogical, and useless?
Now I am talking about the Generics version. Haven't looked at the other API just yet..
-- Main.floersh - 27 Dec 2007
I wish I could retrieve an OffsetDateTime by calculating the span of a Duration trough a CompositeDateAndTimeInterval. The composite could behave as this:
CompositeTimeInterval working_hours = EnhancedTimeInterval(Mon tru fri 8:00 to 20:00)
TimeInterval lunchbreak = 12:00 to 12:45
CompositeDateWithoutTime belgiumBankHolidays2008 = 1 Jan 2008, 23 Mar 2008, 24 Mar 2008, 1 May 2008, 11 May 2008, 12 May 2008, 21 Jul 2008, 15 Aug 2008, 1 Nov 2008, 11 Nov 2008, 25 Dec 2008
CompositeDateWithoutTime specialOpeningDays = Sun 20 Feb (launch of our new super awaited product), Sun 21 Dec (shopping day before Xmas)
CompositeTimeInterval working_hours_2008 = new CompositeTimeInterval()
working_hours_2008.include(working_hours)
working_hours_2008.exclude(lunchbreak)
working_hours_2008.exclude(belgiumBankHolidays2008)
working_hours_2008.include(specialOpeningDays)
Use cases
When
a customer ticket is opened for more than two hours during working_hours_2008
and state is urgent
then
send a reminder to the support team
When
a customer ticket is opened for more than five hours during working_hours_2008
and state is urgent
then
escalate ticket
When
a customer ticket is opened for more than 100 hours during working_hours_2008
then
report it to the boss
Or to estimate a work unit:
Duration job_duration = 100h
Instant now = now()
Instant planned_job_end = CompositeTimeInterval.span(now, job_duration, agenda_2008)
It would require to enhance Time intervals: Mon tru fri 8:00 to 20:00 (or 8:00 p.m. to 8 a.m.) Also required: "Every first tuesday of the month" calculation method.
Suggestions for a better name are welcome: Date and Time intervals aggregates? Agenda? Complex Time intervals? Time Intervals sets?
-- Main.rusinsky - 27 Dec 2007
The current code for dayOfWeek(ReadableDate dateProvider) appears to be incomplete. I'd suggest using an algorithm called Zeller's Congruence (http://en.wikipedia.org/wiki/Zeller's_congruence).
An example implementation:
private int dayOfWeek(int day, int month, int year) {
day += ((month