Procházet zdrojové kódy

BETA: Fixing Util.formatAdena() method sometimes it misses some zero's.
* Reported by: lion

Rumen Nikiforov před 12 roky
rodič
revize
0bfbe3299b

+ 5 - 19
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

@@ -20,10 +20,12 @@ package com.l2jserver.gameserver.util;
 
 import java.io.File;
 import java.text.DateFormat;
+import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 
 import javolution.text.TextBuilder;
 import javolution.util.FastList;
@@ -43,6 +45,8 @@ import com.l2jserver.util.file.filter.ExtFilter;
  */
 public final class Util
 {
+	private static NumberFormat ADENA_FORMATTER = NumberFormat.getIntegerInstance(Locale.ENGLISH);
+	
 	public static void handleIllegalPlayerAction(L2PcInstance actor, String message, int punishment)
 	{
 		ThreadPoolManager.getInstance().scheduleGeneral(new IllegalPlayerAction(actor, message, punishment), 5000);
@@ -395,25 +399,7 @@ public final class Util
 	 */
 	public static String formatAdena(long amount)
 	{
-		String s = "";
-		long rem = amount % 1000;
-		s = Long.toString(rem);
-		amount = (amount - rem) / 1000;
-		while (amount > 0)
-		{
-			if (rem < 99)
-			{
-				s = '0' + s;
-			}
-			if (rem < 9)
-			{
-				s = '0' + s;
-			}
-			rem = amount % 1000;
-			s = Long.toString(rem) + "," + s;
-			amount = (amount - rem) / 1000;
-		}
-		return s;
+		return ADENA_FORMATTER.format(amount);
 	}
 	
 	/**