This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Date

vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
How do I get today's date in java?
I am actually using javamail to read messages. So i want to pick those messages from yest aftder 2 pm to today. How can I do that?
Thanks,
Vidhya
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Date rightNow = new Date(); // Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
or:
Calendar rightNow = Calendar.getInstance();


"JavaRanch, where the deer and the Certified play" - David O'Meara
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Let's try to keep the discussion for this one in one place. I'm closing this thread; follwups can go here. Thanks.


"I'm not back." - Bill Harding, Twister
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Date
 
Similar Threads
Date in java
Question on Creation of a Date Object
SimpleDateFormat
Convert sql date to util date
moving files to different folders