This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 755
how do i get current date in java... ???


Jigar Naik


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
"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: 755
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: 3506
    
  14
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: 41635
    
  55
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: date problem