/*
* @author XueWeiWei
* @date 2019/8/26 16:22
*/
package com.nps.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.util.Date;
public class DateUtils {
private static final org.slf4j.Logger logger = null;
private static final java.time.format.DateTimeFormatter yyyyMMddFmt = null;
public DateUtils() {
}
public static boolean sameDate(java.util.Date d1, java.util.Date d2){
return d1.equals(d2);
}
public static java.time.LocalDate getDateByStr(java.lang.String dateStr, java.lang.String fmt) {
try {
return dateToLocalDate(new SimpleDateFormat().parse(dateStr+fmt));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static java.time.LocalDate dateToLocalDate(java.util.Date date) {
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
public static java.time.LocalDateTime dateToLocalDateTime(java.util.Date date){
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}
public static java.util.Date localDateToDate(java.time.LocalDate localDate){
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static java.util.Date localDateTimeToDate(java.time.LocalDateTime localDateTime){
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static java.lang.String dateToString(java.util.Date date){ return date.toString();}
public static void main(String[] args) {
}
}