瀏覽代碼

添加parseDateStr方法

zhouxianguang 6 年之前
父節點
當前提交
aed041c1f4
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/DateUtil.java

+ 10 - 4
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/DateUtil.java

@@ -209,7 +209,8 @@ public class DateUtil {
 	 * @author xtwin <br/>
 	 * @version 2013-11-27 上午09:59:37 <br/>
 	 */
-	private static SimpleDateFormat getFormat(String pattern) {
+	private static SimpleDateFormat
+	getFormat(String pattern) {
 		SimpleDateFormat sdf = formats.get(pattern);
 		
 		if (null == sdf) {
@@ -247,9 +248,14 @@ public class DateUtil {
 		return strtodate;
 	}
 
+	public static String parseDateStr(Long times)
+	{
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+		ParsePosition pos = new ParsePosition(0);
+		return formatter.format(new Date(times));
+	}
+
 	public static void main(String[] args) {
-		for (int i = 0; i < 20; i++) {
-			System.out.println(DateUtil.getRandomCurrentTimeStamp());
-		}
+		System.out.print(parseDateStr(1543766400000l));
 	}
 }