I want to convert a java.util.Date object to a String in Java.
java.util.Date
String
The format is 2010-05-30 22:15:52
2010-05-30 22:15:52
Why don't you use Joda (org.joda.time.DateTime)? It's basically a one-liner.
Date currentDate = GregorianCalendar.getInstance().getTime(); String output = new DateTime( currentDate ).toString("yyyy-MM-dd HH:mm:ss"); // output: 2014-11-14 14:05:09