Solved

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

Posted on 2004-09-14
4
227 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

685 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