Browse Source

Adding util's formatDate method for date formatting by Tryskell

BiggBoss 13 years ago
parent
commit
44db3283ab
1 changed files with 16 additions and 0 deletions
  1. 16 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

+ 16 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

@@ -13,6 +13,7 @@
 package com.l2jserver.gameserver.util;
 
 import java.io.File;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
@@ -361,6 +362,21 @@ public final class Util
 		return s;
 	}
 	
+    /**
+     * Format the given date on the given format
+     * @param date : the date to format.
+     * @param format : the format to correct by.
+     * @return a string representation of the formatted date.
+     */
+    public static String formatDate(Date date, String format)
+    {
+        final DateFormat dateFormat = new SimpleDateFormat(format);
+        if (date != null)
+            return dateFormat.format(date);
+       
+        return null;
+    }
+	
 	/**
 	 * @param <T> 
 	 * @param array - the array to look into