From 3d5e14512c1b13605bc1306c6235a7f1dfcf8e36 Mon Sep 17 00:00:00 2001 From: infin_caishuxiao Date: Fri, 23 Feb 2018 23:23:03 +0800 Subject: [PATCH] =?UTF-8?q?pom=20parent=E5=B1=82=E7=BA=A7=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor-collection-dispatcher/pom.xml | 4 +- .../com/infincash/util/Jdk8DateUtils.java | 38 +++++++++++++++++++ .../xxl-job-executor-db/pom.xml | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/util/Jdk8DateUtils.java diff --git a/infintech-executors/executor-collection-dispatcher/pom.xml b/infintech-executors/executor-collection-dispatcher/pom.xml index 19670acd..0db0707b 100644 --- a/infintech-executors/executor-collection-dispatcher/pom.xml +++ b/infintech-executors/executor-collection-dispatcher/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.xuxueli - xxl-job-executor-samples + infintech-executors 1.9.1-SNAPSHOT executor-collection-dispatcher @@ -18,7 +18,7 @@ UTF-8 UTF-8 - 1.7 + 1.8 diff --git a/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/util/Jdk8DateUtils.java b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/util/Jdk8DateUtils.java new file mode 100644 index 00000000..a1521037 --- /dev/null +++ b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/util/Jdk8DateUtils.java @@ -0,0 +1,38 @@ +package com.infincash.util; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Date; + +public class Jdk8DateUtils { + public static LocalDateTime toLocalDateTime(Date date) { +// ZoneId utc7 = ZoneId.of("Asia/Ho_Chi_Minh"); + + Instant ins = date.toInstant(); + return LocalDateTime.ofInstant(ins, ZoneId.systemDefault()); + } + + public static String toString(LocalDateTime ldt) { + return toString(ldt, "yyyy-MM-dd HH:mm:ss"); + } + + public static String toString(LocalDateTime ldt, String formatter) { + LocalDate localDate = ldt.toLocalDate(); + //LocalDate 格式化 HH:mm:ss会抛异常java.time.temporal.UnsupportedTemporalTypeException + String sDate = ldt.format(DateTimeFormatter.ofPattern(formatter)); + return sDate; + } + + public static long substract(Date a, Date b) { + LocalDateTime aa = toLocalDateTime(a); + LocalDateTime bb = toLocalDateTime(b); + return aa.toLocalDate().toEpochDay() - bb.toLocalDate().toEpochDay(); + } + + public static void main(String[] args) { + System.out.println(toString(toLocalDateTime(new Date()))); + } +} diff --git a/infintech-executors/xxl-job-executor-db/pom.xml b/infintech-executors/xxl-job-executor-db/pom.xml index b9e8411b..7d6f5b94 100644 --- a/infintech-executors/xxl-job-executor-db/pom.xml +++ b/infintech-executors/xxl-job-executor-db/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.xuxueli - xxl-job-executor-samples + infintech-executors 1.9.1-SNAPSHOT xxl-job-executor-db