• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

how do i get day of the week from the date

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
i want to get the day of the week for a particular date.
assume the date is in the dd/mm/yyyy format
then in java how can i display the day for this date
for example..for 06/08/2002 i want Tue to be the output.
Please help.
thanx in advance
Chhaya
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is no easy way about it and it involves alot of validating u will have to create a table of the days of the week get the system date and then u also have to create the days of the week in num it's quite complicated i hope this little piece helps
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Calendar API to get the day of the week.Let's say the date is 6th Aug 2002.Set the calendar object as following:
cal.set(2002,7,6);
where - 2002 is the year
7 - month (Jan is 0 so Aug is 7)
6 - date

Output :
Day is 3
which is TUESDAY
(SUNDAY -1,MONDAY - 2 and so on)
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chhaya Dhanani:
hi all,
i want to get the day of the week for a particular date.
assume the date is in the dd/mm/yyyy format
then in java how can i display the day for this date
for example..for 06/08/2002 i want Tue to be the output.
Please help.
thanx in advance
Chhaya

I don't think that this is too hard using the java.text.SimpleDateFormat class:

Jamie
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic