1、日期格式转换为时间戳
Long timestampLogin=Long.parseLong(Date2TimeStamp("2020-02-26 11:52:00","yyyy-MM-dd HH:mm:ss"));
public static String Date2TimeStamp(String dateStr, String format) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(dateStr).getTime() / 1000);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
2、时间戳转换为日期
Date date=new Date(System.currentTimeMillis());
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String DateDTSTART=sdf.format(date);
Log.d(Tag,DateDTSTART)
UTC + 时区差 = 本地时间