⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 currency.java

📁 老外的在线考试
💻 JAVA
字号:
/* * Core - Library of useful classes that are used in many CyberDemia projects. * Copyright (C) 2003 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA  02111-1307, USA. * * See the COPYING file located in the top-level-directory of * the archive of this library for complete text of license. */package com.cyberdemia.value;import com.cyberdemia.util.Format;/*** <p>* Currency encapsulates a currency/money value.* This can be treated as a simple Javabean,* with a double property named <i>value</i>.* </p>* <p>* Note: In the default English-US locale, a value of* 1.0 represents $1.00.* </p>* <p>* The formatting to a String is locale dependent,* hence this class depends on <code>com.cyberdemia.util.Format</code>* to perform formatting and manage locale.* </p>** @author  Alexander Yap* @see com.cyberdemia.util.Format* @version $Revision: 1.2 $ at $Date: 2004/02/18 08:35:30 $ by $Author: alexycyap $*/public class Currency extends DoubleType{	/**	* Default constructor	*/	public Currency()	{		super();	}	/**	* Convenient constructor.	*/	public Currency( double val)	{		super(val);	}	/**	* <p>	* Gets value as a String, using default settings and current locale as	* set in <code>com.cyberdemia.util.Format</code>.	* </p>	* <p><b>Note:</b>The <code>toString()</code> method calls this method.	* </p>	*	*	* @return Currency string for the current locale.	* @see com.cyberdemia.util.Format#formatCurrency( double )	*/	public String getStringValue()	{		return Format.formatCurrency( getValue() );	}	/**	* Converts to a String, using current locale as set in	* <code>com.cyberdemia.util.Format</code>.	* The number of fractional digits can be specified.	* Grouping can be enabled or disabled.	*	* @param    minFracDigits  minimum number of fractional digits	* @param    maxFracDigits  maximum number of fractional digits	* @param    grouped        enable or disable grouping	* @return Currency string for the current locale.	* @see com.cyberdemia.util.Format#formatCurrency( double, int, int, boolean )	*/	public String toString(int minFracDigits, int maxFracDigits, boolean grouped)	{		return Format.formatCurrency( getValue(), minFracDigits, maxFracDigits, grouped);	}	/**	* Creates a clone of this Currency object.	* @return  Clone of this object.	*/	public Object clone()	{		return new Currency( getValue() );	}	/**	* Returns true if this currency can be treated as 0.	* Currency need not require a high level of precision.	* So if the absolute value is less than 0.0001, it is treated as 0.	*/	public boolean isZero()	{		return (Math.abs( getValue() )<0.0001); 	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -