• Post Reply Bookmark Topic Watch Topic
  • New Topic

I need a date... No, really!  RSS feed

 
George Larry
Ranch Hand
Posts: 52
  • 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
Sheriff
Posts: 10950
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • 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
  • 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
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!