//SimpleDateFormate线程不安全,DateTimeFormatter线程安全
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:s");
LocalDateTime ldt = LocalDateTime.now();
String x = "2019-07-03 10:07:26";
LocalDateTime ll = LocalDateTime.parse(x, dtf);
//ll.atZone(ZoneId.of("CTT")).toInstant().getEpochSecond();
ll.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
ll.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
System.out.println(ll.atZone(ZoneId.of("Asia/Shanghai")).toInstant().getEpochSecond());
String date = ldt.format(dtf);
System.out.println(date);
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31506529/viewspace-2649807/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31506529/viewspace-2649807/