Moved the currency{Pennies} from StringTool to StringUtil. Made wrappers

in StringTool so we can keep using them.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1274 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
eric
2003-10-23 16:09:34 +00:00
parent 22b71d34b9
commit 6154db914b
2 changed files with 26 additions and 9 deletions
@@ -1,9 +1,9 @@
//
// $Id: StringUtil.java,v 1.58 2003/10/08 23:52:50 ray Exp $
// $Id: StringUtil.java,v 1.59 2003/10/23 16:09:34 eric Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
//
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
@@ -161,6 +161,22 @@ public class StringUtil
return false;
}
/**
* Converts a number representing dollars to a currency display string.
*/
public static String currency (double value)
{
return _curFormatter.format(value);
}
/**
* Converts a number representing pennies to a currency display string.
*/
public static String currencyPennies (double value)
{
return currency(value / 100.0);
}
/**
* Formats a floating point value with useful default rules;
* ie. always display a digit to the left of the decimal and display
@@ -509,7 +525,7 @@ public class StringUtil
buf.append(closeBox);
} else {
// fall back on the general purpose
// fall back on the general purpose
toString(buf, val);
}
}
@@ -1102,4 +1118,8 @@ public class StringUtil
_ffmt.setMinimumFractionDigits(1);
_ffmt.setMaximumFractionDigits(2);
}
/** Used to easily format numbers as currency. Bling Bling. */
protected static NumberFormat _curFormatter =
NumberFormat.getCurrencyInstance();
}
@@ -1,5 +1,5 @@
//
// $Id: StringTool.java,v 1.11 2003/10/08 23:52:50 ray Exp $
// $Id: StringTool.java,v 1.12 2003/10/23 16:09:34 eric Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -59,7 +59,7 @@ public class StringTool
*/
public static String currency (double value)
{
return _curFormatter.format(value);
return StringUtil.currency(value);
}
/**
@@ -67,7 +67,7 @@ public class StringTool
*/
public static String currencyPennies (double value)
{
return currency(value / 100.0);
return StringUtil.currencyPennies(value);
}
/**
@@ -77,7 +77,4 @@ public class StringTool
{
return HTMLUtil.makeParagraphs(text);
}
protected static NumberFormat _curFormatter =
NumberFormat.getCurrencyInstance();
}