• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need a date... No, really!

 
George Larry
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get todays date as a string in the form mm/dd/yy?
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try SimpleDateFormat("MM/dd/yy") or if you are using JSPs, you might try using the Jakarta DateTime Taglibs
Junilu
 
George Larry
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but how do I get TODAY's date?... that's the first part, then I need to convert it to a string in the mm/dd/yy format.
Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.Date now = new java.util.Date();
Initializes "now" to the current time and date. Then you can use the dateformatting code listed above to get it as a String.
This isn't JSP-related, BTW -- it's basic Java.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic