import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
/**
* @Author: zhangdeheng
* @Date: 2019-08-20 13:43
* @Version 1.0
*/
public class TimeUtils {
public static String formatDate(Date date,String formatStr) {
DateTime dateTime = new DateTime(date);
return dateTime.toString(formatStr);
}
public static Long parse(String strDate,String formatStr) {
DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern(formatStr);
DateTime dateTime = DateTime.parse(strDate, dateTimeFormat);
dateTime = dateTime.plusDays(1);
return dateTime.getMillis();
}
public static void main(String[] args) {
String s = formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
Long parse = parse(s, "yyyy-MM-dd HH:mm:ss");
System.out.println(s+" "+parse);
}
}