aspose file tools*
The moose likes Beginning Java and the fly likes How to find day from the week using date format? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to find day from the week using date format?" Watch "How to find day from the week using date format?" New topic
Author

How to find day from the week using date format?

Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
How can I find day from the week using date format like 27/02/2006. from this date format I have to find that day is Monday.
I mean using date format how we can find day(like monday, or tuesday or wednus day) from week.
karthikeyan Chockalingam
Ranch Hand

Joined: Sep 06, 2003
Posts: 259


Please refer http://java.sun.com/j2se/1.4.2/docs/api/constant-values.html#java.util.Calendar.YEAR
for constant values

[ February 27, 2006: Message edited by: karthi keyan ]
[ February 27, 2006: Message edited by: karthi keyan ]

http://www.skillassert.com


Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
import java.util.*;

public class FindDay {

public static void main(String args[]){
Calendar cal = Calendar.getInstance();
cal.set(2006,2,27);
System.out.println("DAY_OF_WEEK =" + cal.get(Calendar.DAY_OF_WEEK));

switch(cal.get(Calendar.DAY_OF_WEEK)){
case Calendar.MONDAY:
System.out.println("Monday");
break;

case Calendar.TUESDAY:
System.out.println("TUESDAY");
break;

case Calendar.WEDNESDAY:
System.out.println("WEDNESDAY");
break;

case Calendar.THURSDAY:
System.out.println("THURSDAY");
break;

case Calendar.FRIDAY:
System.out.println("FRIDAY");
break;

case Calendar.SATURDAY :
System.out.println("SATURDAY");
break;

case Calendar.SUNDAY :
System.out.println("SUNDAY");
break;

}

}
}


Sharing is learning
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

If you want to parse "27/02/2006" as it is,
You may want to have a look at :

SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date date = format.parse("27/02/2006");


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find day from the week using date format?