Meaningless Drivel is fun!
The moose likes JSP and the fly likes I need a date... No, really! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "I need a date... No, really!" Watch "I need a date... No, really!" New topic
Author

I need a date... No, really!

George Larry
Ranch Hand

Joined: Nov 07, 2001
Posts: 52
How can I get todays date as a string in the form mm/dd/yy?
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 6286
    
  15

try SimpleDateFormat("MM/dd/yy") or if you are using JSPs, you might try using the Jakarta DateTime Taglibs
Junilu


Junilu - [How to Ask Questions] [How to Answer Questions]
George Larry
Ranch Hand

Joined: Nov 07, 2001
Posts: 52
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

Joined: Jun 25, 2001
Posts: 17035
    
  26

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.


An IDE is no substitute for an Intelligent Developer.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: I need a date... No, really!
 
jQuery in Action, 3rd edition