aspose file tools*
The moose likes Beginning Java and the fly likes how do i get day of the week from the date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how do i get day of the week from the date" Watch "how do i get day of the week from the date" New topic
Author

how do i get day of the week from the date

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
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

Joined: May 06, 2002
Posts: 39
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

Joined: Sep 07, 2000
Posts: 128
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)


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how do i get day of the week from the date
 
Similar Threads
date question
date problem
How to get day, month, and year seperate from date
how to caculate first day / last day of a week ?
first day of the current week