• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Date,Calendar class

Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For 3 days ,
I am stuck in Date ,Currency packages.

I could not make out the difference between DAte class,Calendar & DateFormat class.
What is specific use of Date & Calendar when they both give time .

Let me help in finishing this topic.

Thank you.
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucky ,
This is an important topic as per exam point of view I scored least in this topic.
Date is old class now but still in use for formatting date and stuff.
Calendar is relatively programmer friendly class.
for e.g.
in Date class
if you say
Date d = new Date();
and now if you print the Date object d you will see current date.
Now if you need to add an hour to current time
it will be something like
d.setTime(d.getTime +3600000);

so just imagine in your application if you need to add a year or a month or some x amount of hours
you will be dead by the time you are done the calculations of adding stuff.

Calendar class is very programmer friendly class
so now if you want to ask a month to a date using Calendar class
which is ab abstract class
Calendar cal= Calendar.getInstance();

so calendar is newer class and used mostly to make things easy for us .
The best way to understand this topic is to write some programs
execute them be innovative and this forum is always there if you are stuck some place

Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic