shjung il y a 9 mois
Parent
commit
98fa71988b

+ 4 - 2
its-asn1/build.gradle

@@ -28,7 +28,7 @@ test {
     useJUnitPlatform()
 }
 
-task runInstallJarLibrary(type:Exec) {
+tasks.register('runInstallJarLibrary', Exec) {
     doFirst {
         println "its-asn1 library install mvn repository..."
         workingDir = file('.')
@@ -38,7 +38,9 @@ task runInstallJarLibrary(type:Exec) {
 }
 jar.finalizedBy runInstallJarLibrary
 
-tasks.withType(JavaCompile) {
+compileJava.options.encoding = 'UTF-8'
+tasks.withType(JavaCompile).configureEach {
     options.compilerArgs << '-Xlint:unchecked'
     options.deprecation = true
+    options.encoding = 'UTF-8'
 }

+ 4 - 2
its-common/build.gradle

@@ -28,7 +28,7 @@ test {
     useJUnitPlatform()
 }
 
-task runInstallJarLibrary(type:Exec) {
+tasks.register('runInstallJarLibrary', Exec) {
     doFirst {
         println "its-common library install mvn repository..."
         workingDir = file('.')
@@ -38,7 +38,9 @@ task runInstallJarLibrary(type:Exec) {
 }
 jar.finalizedBy runInstallJarLibrary
 
-tasks.withType(JavaCompile) {
+compileJava.options.encoding = 'UTF-8'
+tasks.withType(JavaCompile).configureEach {
     options.compilerArgs << '-Xlint:unchecked'
     options.deprecation = true
+    options.encoding = 'UTF-8'
 }

+ 16 - 4
its-common/src/main/java/com/its/common/utils/Elapsed.java

@@ -29,17 +29,29 @@ public class Elapsed {
 		sTime = System.nanoTime();
 	}
 
+	public String elapsedTimeStr() {
+		return elapsedTimeStr(getElapsed());
+	}
+
 	public static String elapsedTimeStr(long elapsed) {
+		long hours = TimeUnit.HOURS.convert(elapsed, TimeUnit.NANOSECONDS);
+		long minutes = TimeUnit.MINUTES.convert(elapsed, TimeUnit.NANOSECONDS);
 		long seconds = TimeUnit.SECONDS.convert(elapsed, TimeUnit.NANOSECONDS);
-		long milliSeconds = TimeUnit.MILLISECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
+		long miliSeconds = TimeUnit.MILLISECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 		long microSeconds = TimeUnit.MICROSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 		long nanoSeconds = TimeUnit.NANOSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 
+		if (hours > 0) {
+			return String.format("Elapsed: %,d hr. %2d min. %2d sec. %3d ms. %3d us. %3d ns.", hours, minutes, seconds, miliSeconds, microSeconds, nanoSeconds);
+		}
+		if (minutes > 0) {
+			return String.format("Elapsed: %2d min. %2d sec. %3d ms. %3d us. %3d ns.", minutes, seconds, miliSeconds, microSeconds, nanoSeconds);
+		}
 		if (seconds > 0) {
-			return String.format("Elapsed: %,d sec. %3d ms. %3d us. %3d ns.", seconds, milliSeconds, microSeconds, nanoSeconds);
+			return String.format("Elapsed: %2d sec. %3d ms. %3d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
 		}
-		if (milliSeconds > 0) {
-			return String.format("Elapsed: %3d ms. %3d us. %3d ns.", milliSeconds, microSeconds, nanoSeconds);
+		if (miliSeconds > 0) {
+			return String.format("Elapsed: %3d ms. %3d us. %3d ns.", miliSeconds, microSeconds, nanoSeconds);
 		}
 		if (microSeconds > 0) {
 			return String.format("Elapsed: --- ms. %3d us. %3d ns.", microSeconds, nanoSeconds);

+ 15 - 0
its-common/src/main/java/com/its/common/utils/TimeUtils.java

@@ -17,6 +17,15 @@ public class TimeUtils {
 
     private TimeUtils() {}
 
+    public static void sleep(long delay) {
+        try {
+            TimeUnit.MILLISECONDS.sleep(delay);
+        }
+        catch (InterruptedException e) {
+//            Thread.currentThread().interrupt();
+        }
+    }
+
     public static String elapsedTime(long startTime, long endTime) {
         return elapsedTimeStr(endTime - startTime);
     }
@@ -100,6 +109,12 @@ public class TimeUtils {
         return sdf.format(today);
     }
 
+    public static String now() {
+        Date today = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(today);
+    }
+
     public static long getCurrentTimeSeconds() {
         Calendar cal = Calendar.getInstance();
         return Math.round((double)cal.getTimeInMillis() / 1000.0D);

+ 4 - 2
its-network/build.gradle

@@ -29,7 +29,7 @@ test {
     useJUnitPlatform()
 }
 
-task runInstallJarLibrary(type:Exec) {
+tasks.register('runInstallJarLibrary', Exec) {
     doFirst {
         println "its-network library install mvn repository..."
         workingDir = file('.')
@@ -39,7 +39,9 @@ task runInstallJarLibrary(type:Exec) {
 }
 jar.finalizedBy runInstallJarLibrary
 
-tasks.withType(JavaCompile) {
+compileJava.options.encoding = 'UTF-8'
+tasks.withType(JavaCompile).configureEach {
     options.compilerArgs << '-Xlint:unchecked'
     options.deprecation = true
+    options.encoding = 'UTF-8'
 }

+ 4 - 2
its-spring/build.gradle

@@ -28,7 +28,7 @@ test {
     useJUnitPlatform()
 }
 
-task runInstallJarLibrary(type:Exec) {
+tasks.register('runInstallJarLibrary', Exec) {
     doFirst {
         println "its-spring library install mvn repository..."
         workingDir = file('.')
@@ -38,7 +38,9 @@ task runInstallJarLibrary(type:Exec) {
 }
 jar.finalizedBy runInstallJarLibrary
 
-tasks.withType(JavaCompile) {
+compileJava.options.encoding = 'UTF-8'
+tasks.withType(JavaCompile).configureEach {
     options.compilerArgs << '-Xlint:unchecked'
     options.deprecation = true
+    options.encoding = 'UTF-8'
 }