Solved

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

Posted on 2004-09-14
4
225 Views
Last Modified: 2010-03-31
How can I do that...
0
Comment
Question by:greedy1
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 12056673
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
 
LVL 14

Expert Comment

by:dfu23
ID: 12056687
Make a date object and use:

Calendar.DAY_OF_WEEK

http://java.sun.com/j2se/1.3/docs/api/java/util/Date.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12056748
System.out.println(new DateFormatSymbols().getWeekdays()[cal.get(Calendar.DAY_OF_WEEK)]);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12057394
8-)
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question