View Javadoc

1   // Created on 27.11.2003
2   package com.pnpconsult.zeiterfassung.util;
3   
4   import java.text.DecimalFormat;
5   import java.text.NumberFormat;
6   
7   /***
8    * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
9    * @version $Id: NumberUtils.java,v 1.2 2004/05/23 16:59:41 powerpete Exp $
10   */
11  public class NumberUtils
12  {
13      private static final NumberFormat LONG = new DecimalFormat("#,##0.00");
14      private static final NumberFormat SHORT = NumberFormat.getInstance();
15      
16      public static String formatLong(double d)
17      {
18          return LONG.format(d);
19      }
20      
21      public static String formatShort(double d)
22      {
23          
24          return SHORT.format(Math.round(d * 100.0D) / 100.0D);
25      }
26  }