Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to track down Infection in a Server 2008 domain user profile 7 48
VB Script to add site to Java Exception List 4 50
Java Timer (static) 9 36
factorial example 4 35
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

920 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