• Post Reply Bookmark Topic Watch Topic
  • New Topic

differnce between calender and date  RSS feed

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

what is the differnce between java.util.Date and java.util.Calender and also suggest me wether calender can be replaced
with date and vice versa .if not why?

looking for your replies
amir
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The chief difference is that Date has no concepts of timezones. So if your code will ever have the need to consider times in multiple timezones, then you should use Calendar instead.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, class Calendar has useful methods to do date arithmetic (adding or subtracting days, months, years etc. from each other).

Actually, the date and calendar APIs in Java's standard library are not so well designed. There is a popular open source third-party library, Joda Time, which is better designed than the standard API. There is also JSR 310, which is a proposal to add a new date and time API similar to Joda Time to the standard library.
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ulf and young
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper,

Thanks for the link to Joda Time. I hadn't heard of it yet; looks like it's worth looking into.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are plans about integrating it into the Java 7 JRE and JDK, so in the future you may not even have to download it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!