import java.text.ParseException; import java.util.Calendar; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; /** * * @author zxf */ public class JavaApplication1 { private static final String DATE_FORMAT = "yyyy-MM-dd' 'HH:mm:ss"; /** * @param args the command line arguments */ public static void main(String[] args) throws ParseException { String time = DateFormatUtils.format(Calendar.getInstance(), DATE_FORMAT); System.out.println(time); Calendar o = DateUtils.toCalendar(DateUtils.parseDate(time, DATE_FORMAT)); System.out.println(o); } }