Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Comma.java

00001 package gov.nasa.arc.ase.util;
00002 
00003 public class Comma {
00004   // Comma
00005   //
00006   // Formats a number with a comma to separate thousands, millions, and so on
00007   //
00008   private static final long thousand = 1000;
00009 
00010   public static String format(long number) {
00011     StringBuffer value = new StringBuffer();
00012 
00013     while(number >= thousand) {
00014       long t = number % thousand;
00015       number /= thousand;
00016 
00017       value.insert(0, t);
00018       if(t < 10) value.insert(0, '0');
00019       if(t < 100) value.insert(0, '0');
00020       value.insert(0, ',');
00021     }
00022     value.insert(0, number);
00023 
00024     return value.toString();
00025   }  
00026 }

Generated at Thu Feb 7 06:42:41 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001