• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Give a date, i.e. 2004-09-14, need it to return TUESDAY.

How can I do that...
0
greedy1
Asked:
greedy1
  • 3
1 Solution
 
CEHJCommented:
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
cal.setTime(sdf.parse("2004-09-14"));
System.out.println(cal.get(Calendar.DAY_OF_WEEK)); // use this to index an array
0
 
dfu23Commented:
Make a date object and use:

Calendar.DAY_OF_WEEK

http://java.sun.com/j2se/1.3/docs/api/java/util/Date.html
0
 
CEHJCommented:
System.out.println(new DateFormatSymbols().getWeekdays()[cal.get(Calendar.DAY_OF_WEEK)]);
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now