File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i get day of the week from the date

 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
khella smith
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Snigdha Solanki
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • 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)
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic