Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic