aspose file tools*
The moose likes Features new in Java 7 and the fly likes Improvements in Dates. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "Improvements in Dates." Watch "Improvements in Dates." New topic
Author

Improvements in Dates.

kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 119
    
    1
Hi,

I write code using java 1.4 and know the concepts of 5. Will it take more time to upgrade till 7? Only opportunity to work on 7 comes when the application servers ship it.

Its always not easy to deal with Dates, first fetching date from the database and converting it into GregorianCalendar, using some customized wrappers to get them in desired format. Are there any improvements in dealing with Dates.

Thanks,
Kumar.
Richard Reese
author
Ranch Hand

Joined: Jul 13, 2011
Posts: 84
    
    5

There have been quite a few changes to Java since 1.4. It is hard to predict how much time it would take to upgrade to Java 7. It depends on several factors including the application type and its needs to use any relevant new features. With regards to date/time, Java 7 has a FileTime class used to represent a time stamp for a file. In addition, there is support for handling the number of weeks an the current week of a year in Java 7. Both of these topics are covered in the book. You are correct when you say working with dates is not easy. Time is a complex topic. Java has provided only incremental date/time improvements with each new version.


Richard Reese
Java 8 New Features: A Practical Heads-Up Guide
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9383
    
    2

kumar naresh wrote:Hi,

I write code using java 1.4 and know the concepts of 5. Will it take more time to upgrade till 7? Only opportunity to work on 7 comes when the application servers ship it.



Upgrading your application to 7 from 1.4 will take considerable amount of time as it depends on your application landscape and what effect it might have on the other interfacing systems. But on the other hand, upgrading your knowledge from Java 1.4 to Java 7 should be a breeze considering the fact that you are an experienced developer. But again this depends on the individual.

From my point of view wherein I recently started venturing in C#, it was not at all difficult to learn the new features like delegates, lambda expressions and of course the C# syntax. I'm enjoying it. I now only have to get used to writing and executing C# code.
kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 119
    
    1
Thank you for the responses.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14153
    
  18

Unfortunately Java 7 does not yet have an improved date and time API.

There is JSR 310, which is a project to add a new date and time API that will probably look a lot like Joda Time. Joda Time is a popular date and time library for Java with a much better designed API than Java's Date and Calendar classes.

See the ThreeTen Project, which is where the new API is being developed.

I hope this is going to be added to Java 8. In the meantime, I highly recommend using the Joda Time library when you have to work with dates and times.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 119
    
    1
Thank you Jesper for the response and Joda seems to be interesting.

But if we take a real time scenario, where if quantities are stored in the daily duration in database and if it has to be represented in terms of Week, Month and Year. A lot of date manipulations get involved to show them in the desired UI format.

In fact it is a case to case scenario but I tried to give an example where Date manipulations are involved.
 
Consider Paul's rocket mass heater.
 
subject: Improvements in Dates.