• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • 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();
cal.setTime(d)
cal.add(Calendar.Month,1);

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

Charandeep
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic