From e59ad937c831a55f4c952a1bc50263214410d25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=B0=E5=B9=B3=E7=BA=BF?= <22250530@qq.com> Date: Mon, 31 Aug 2015 16:38:52 +0800 Subject: [PATCH] --- src/com/wentch/redkale/util/Utility.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/com/wentch/redkale/util/Utility.java b/src/com/wentch/redkale/util/Utility.java index 0d14d9764..717a86c2d 100644 --- a/src/com/wentch/redkale/util/Utility.java +++ b/src/com/wentch/redkale/util/Utility.java @@ -19,6 +19,8 @@ import javax.net.ssl.*; */ public final class Utility { + private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%tL"; + private static final Charset UTF_8 = Charset.forName("UTF-8"); private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; @@ -67,17 +69,22 @@ public final class Utility { private Utility() { } - public static void println(ByteBuffer buffer) { + public static String now() { + return String.format(format, System.currentTimeMillis()); + } + + public static void println(String string, ByteBuffer buffer) { if (buffer == null || !buffer.hasRemaining()) return; byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes); buffer.flip(); - println(bytes); + println(string, bytes); } - public static void println(byte... bytes) { + public static void println(String string, byte... bytes) { if (bytes == null) return; StringBuilder sb = new StringBuilder(); + if (string != null) sb.append(string); sb.append(bytes.length).append(".["); boolean last = false; for (byte b : bytes) {