日期转换DateTime

Date日期 转换为 String

DateTimeFormatter dateFormatter = 
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
String time =
new DateTime(visitorInvite.getInviteTime()).toString(dateFormatter);

String 日期 转换为 Date

DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");

String sdate = param.getDate();

DateTime inviteDate = formatter.parseDateTime(sdate);

Date date = inviteDate.toDate();

Date <====> DateTime

DateTime.toDate();

new DateTime(Date);

String <====> DateTime

DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");

DateTime s= formatter.parseDateTime(string);

Sting s =new DateTime(date).toString(formatter )

起止时间

DateTime endTime = 
dateTime.withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59);
DateTime startTime = 
dateTime.withHourOfDay(00).withMinuteOfHour(00).withSecondOfMinute(00);

//过期时间在此刻之前

new DateTime(date).isBeforeNow();

 

你可能感兴趣的:(日期转换DateTime)