atxman
asked on
Format today's date in YYYYMMDD format
I am trying to format today's date to YYYYMMDD format by:
String today = new SimpleDateFormat("YYYYMMDD ").parse(D ateFormat. getDateIns tance(Date Format.MED IUM).forma t(Calendar .getInstan ce().getTi me())).toS tring();
However, what I am getting is the following error:
java.text.ParseException: Unparseable date: "Sep 28, 2015"
I am needing 20150928. Anyone know how to accomplish this?
Thanks
String today = new SimpleDateFormat("YYYYMMDD
However, what I am getting is the following error:
java.text.ParseException: Unparseable date: "Sep 28, 2015"
I am needing 20150928. Anyone know how to accomplish this?
Thanks
Your format string is a little off. Check the Javadocs and try again. Your exception is happening because you're calling the parse() method. You don't need that, since you're formatting the date, not parsing it. Take it out and fix the format string and things should work better.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the insight. very helpful