File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date problem

 
Jigar Naik
Ranch Hand
Posts: 761
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get current date in java... ???
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.)
 
Jigar Naik
Ranch Hand
Posts: 761
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is not working...
java.util.Date today = new java.util.Date();
today.getDate();

i tried this methhod depricated...
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Javadoc for the Date class, it will tell you what is recommended instead.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic