import java.text.*; ... ... ... SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); java.util.Date date = java.util.Calendar.getInstance().getTime(); System.out.println(sf.format(date));
Tuesday, June 15, 2004
Java Quick Tip of the Day: Getting the Date in YYYYMMDD Format
There are times when you need to return a date as string in YYYYMMDD format. Here's a simple way to do it:
Subscribe to:
Post Comments (Atom)
3 comments:
Thanks for the tip!
Could you please get a Date with a Date type (not in String type)in YYYYMMDD format?
Tim,
Are you asking for an example or are you wanting me to change my example? Although I didn't explain it in my blog, the example I showed was based on a need that one of my staff had. If you'd like, I can post other examples of using/manipulating Date and/or Calendar objects.
Post a Comment