Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now