Java 时间格式转换
Date to String
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime);
Date to DateTime
DateTime time = new DateTime(new Date());
Date to String
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format("2018-4-23 23:12:16");
Data to TimeStamp
new Timestamp(new Date().getTime())
DateTime To Calendar
Calendar calendar = Calendar.getInstance();
dateTime = new DateTime(calendar);
DateTime to Date
Date date = time.toDate();
DateTime to String
String time = dateTime.toString("yyyy-MM-dd HH:mm:ss");
String to Data
Date date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2018-4-23 23:12:16");
String to DateTime
DateTimeFormatter format = DateTimeFormat .forPattern("yyyy-MM-dd HH:mm:ss");
DateTime dateTime = DateTime.parse("2018-4-23 23:12:16", format);
有什么不同见解可以在评论区共同讨论