日期转换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();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM