This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
newbie needs to know how do get todays date
Shannon Jaye
Greenhorn
Joined: Sep 19, 2002
Posts: 2
posted
Sep 19, 2002 09:56:00
0
I am a total beginner, and I have to get today's date and todays DAY
I need to grab a picture of the week.
SO i have the case statement worked out:
switch (day){ case GregorianCalendar.Sunday: sundate = dt; break; case GregorianCalendar.Monday: sundate = dt.add(GregorainCalendar.Date, -1); break; case GregorianCalendar.Tuesday: sundate = dt.add(GregorainCalendar.Date, -2); break; case GregorianCalendar.Wednesday: sundate = dt.add(GregorainCalendar.Date, -3); break; case GregorianCalendar.Thursday: sundate = dt.add(GregorainCalendar.Date, -4); break; case GregorianCalendar.Friday: sundate = dt.add(GregorainCalendar.Date, -6); break; case GregorianCalendar.Saturday: sundate = dt.add(GregorainCalendar.Date, -6); break; }
I am not sure if the GregorianCalendar.Saturday sytax is correct...
SO in conclusion.. how do I get todays date, and how do I get the DAY of week?
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
Sep 19, 2002 11:33:00
0
GregorianCalendar
gc = new
GregorianCalendar
();
Associate Instructor - Hofstra University
Amazon Top 750 reviewer
-
Blog - Unresolved References
-
Book Review Blog
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
2
I like...
posted
Sep 19, 2002 11:50:00
0
The API Reference is your friend:
http://java.sun.com/j2se/1.4/docs/api/
java.util.Calendar cal = new java.util.GregorianCalendar(); int day_of_week = cal.get(Calendar.DAY_OF_WEEK); java.util.Date today = cal.getTime(); // if today were Sept 19, 2002 System.out.println(day_of_week); // 5 System.out.println(cal.get(java.util.Calendar.DAY_OF_MONTH)); // 19 System.out.println(today); // Thu Sep 19 13:48:44 EDT 2002
[ September 19, 2002: Message edited by: Junilu Lacar ]
Junilu - [
How to Ask Questions
] [
How to Answer Questions
] [
MiH
]
Shannon Jaye
Greenhorn
Joined: Sep 19, 2002
Posts: 2
posted
Sep 19, 2002 12:14:00
0
Thanks TONS! I really apreciate it
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: newbie needs to know how do get todays date
Similar Threads
Help on date and Calendar Object
JSP calendar problem
Changing the date format
i want to get the month of a particular date
Substracting days in java
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter