wood burning stoves 2.0*
The moose likes Java in General and the fly likes date problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "date problem" Watch "date problem" New topic
Author

date problem

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
how do i get current date in java... ???


Jigar Naik


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
"new java.util.Date()" gives you a date object to work with, from which you can extract the various parts (day, month, year, hour, weekday, etc.)


Ping & DNS - my free Android networking tools app
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
this is not working...
java.util.Date today = new java.util.Date();
today.getDate();

i tried this methhod depricated...
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
If you look at the Javadoc for the Date class, it will tell you what is recommended instead.


Joanne
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
It works just fine. Unless you need timezone support (which the Date class does not have), you can use the deprecated Date methods with no problems - they're not broken in the way other deprecated methods and classes are.
John Bartlett
Ranch Hand

Joined: Jan 25, 2006
Posts: 116
Hey,

You are much better off using the Calendar Class as most of the Date class has been deprecated.

//gets the current date
Calendar rightNow = Calendar.getInstance();

John
 
 
subject: date problem
 
Similar Threads
about dataBase books
WA #1.....word association
How can I get sysdate in java?
Head First Design Patterns Release Date
Another format check :P