import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
/**
* Created by Administrator on 2019/3/25.
*/
public class datatimeutil {
public static Date strtodate(String datetimestr, String formatestr){
DateTimeFormatter dateTimeFormat= DateTimeFormat.forPattern(formatestr);
DateTime dateTime=dateTimeFormat.parseDateTime(datetimestr);
return dateTime.toDate();
}
public static String datetostr(Date date, String formatestr){
if(date==null){
return "";
}
DateTime dateTime=new DateTime(date);
return dateTime.toString(formatestr);
}
}
转载于:https://www.cnblogs.com/qinyios/p/11062672.html