Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Currency Symbol problem

Have Programming Question? Ask it here!
 
 
 


Sreenivasulu
Currency Symbol problem
1 Answer(s)      3 years and 9 months ago
Posted in : JSP-Servlet


Hi All,

My Server side code:
--------------------
NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
Currency currency = Currency.getInstance("MYR"); // Malaysia Code
numberFormat.setCurrency(currency);
int num = 12345;
I want to print this in a JSP Page by using numberFormat.format(num).


When I executed the above code in a browser with setting en-us language,
it is showing MYR 12345 like that showing. I want to show this like
RM 12345.
How to solve this?

Any help or idea is greatly appreciated,
Sreenivasulu Arveti.





Advertisement
View Answers

October 13, 2010 at 9:26 PM


Hi,

The java.util.Locale class defines the available local:
Locale.CANADA
Locale.CANADA_FRENCH
Locale.CHINA
Locale.ENGLISH
Locale.ITALY
etc.

If you call the Currency.getInstance(local); then it will give you Currency of that local. But it some cases it Currency is not available then it will give exception. So, while getting the currency for a local put it in the try can catch block.

The following code examples prints the currency of locals if avaialble.

<pre class="prettyprintlang-java">

import java.util.Currency;
import java.util.Locale;
import java.text.DateFormatSymbols;


public class JavaCurrencySymbol {


public static void main(String[] args) {
//Getting currency symbold by specifying the locals
Currency currency = Currency.getInstance(Locale.US);
System.out.println("United States: " + currency.getSymbol());

currency = Currency.getInstance(Locale.UK);
System.out.println("United Kingdom: " + currency.getSymbol());

currency = Currency.getInstance(Locale.FRANCE);
System.out.println("France: " + currency.getSymbol());

currency = Currency.getInstance(Locale.FRANCE);
System.out.println("France: " + currency.getSymbol());

//Displaying currency symbols of all the locals

Locale[] locals = Locale.getAvailableLocales();
for (int i=0; i<locals.length; i++){
Locale local = locals[i];
Currency curr = null;
try{
curr = Currency.getInstance(local);

}catch(Exception e){

}

if(curr!=null){
System.out.println("Local is: " + local + ", Currency Symbol is: "
+ curr.getSymbol());
}else{
System.out.println("Local is: " + local );
}

}

}

}
</pre>

The output of the code is as shown below:


C:\1111>java JavaCurrencySymbol
United States: $
United Kingdom: GBP
France: EUR
France: EUR
Local is: es_PE, Currency Symbol is: PEN
Local is: en
Local is: es_PA, Currency Symbol is: PAB
Local is: sr_BA, Currency Symbol is: BAM
Local is: mk
Local is: es_GT, Currency Symbol is: GTQ
Local is: no_NO, Currency Symbol is: NOK
Local is: sq_AL, Currency Symbol is: ALL
Local is: bg
Local is: hu
Local is: pt_PT, Currency Symbol is: EUR
Local is: el_CY, Currency Symbol is: EUR
Local is: mk_MK, Currency Symbol is: MKD
Local is: sv
Local is: de_CH, Currency Symbol is: CHF
Local is: en_US, Currency Symbol is: $
Local is: fi_FI, Currency Symbol is: EUR
Local is: is
Local is: cs
Local is: en_MT, Currency Symbol is: EUR
Local is: sl_SI, Currency Symbol is: EUR
Local is: sk_SK, Currency Symbol is: SKK
Local is: it
Local is: tr_TR, Currency Symbol is: TRY
Local is: no
Local is: en_GB, Currency Symbol is: GBP
Local is: sr_CS, Currency Symbol is: CSD
Local is: lt
Local is: ro
Local is: en_NZ, Currency Symbol is: NZD
Local is: no_NO_NY, Currency Symbol is: NOK
Local is: lt_LT, Currency Symbol is: LTL
Local is: es_NI, Currency Symbol is: NIO
Local is: nl
Local is: ga_IE, Currency Symbol is: EUR
Local is: fr_BE, Currency Symbol is: EUR
Local is: es_ES, Currency Symbol is: EUR
Local is: fr_CA, Currency Symbol is: CAD
Local is: et_EE, Currency Symbol is: EEK
Local is: sr_RS, Currency Symbol is: RSD
Local is: es_US, Currency Symbol is: $
Local is: es_MX, Currency Symbol is: MXN
Local is: in_ID, Currency Symbol is: IDR
Local is: ru
Local is: lv
Local is: es_UY, Currency Symbol is: UYU
Local is: lv_LV, Currency Symbol is: LVL
Local is: pt_BR, Currency Symbol is: BRL
Local is: hr
Local is: et
Local is: es_DO, Currency Symbol is: DOP
Local is: fr_CH, Currency Symbol is: CHF
Local is: es_VE, Currency Symbol is: VEF
Local is: en_PH, Currency Symbol is: PHP
Local is: fi
Local is: de_AT, Currency Symbol is: EUR
Local is: es
Local is: nl_NL, Currency Symbol is: EUR
Local is: es_EC, Currency Symbol is: $
Local is: be
Local is: is_IS, Currency Symbol is: ISK
Local is: es_CO, Currency Symbol is: COP
Local is: es_CR, Currency Symbol is: CRC
Local is: es_CL, Currency Symbol is: CLP
Local is: en_ZA, Currency Symbol is: ZAR
Local is: el_GR, Currency Symbol is: EUR
Local is: it_IT, Currency Symbol is: EUR
Local is: ca
Local is: hu_HU, Currency Symbol is: HUF
Local is: fr
Local is: en_IE, Currency Symbol is: EUR
Local is: uk_UA, Currency Symbol is: UAH
Local is: pl_PL, Currency Symbol is: PLN
Local is: fr_LU, Currency Symbol is: EUR
Local is: nl_BE, Currency Symbol is: EUR
Local is: en_IN, Currency Symbol is: INR
Local is: ca_ES, Currency Symbol is: EUR
Local is: es_BO, Currency Symbol is: BOB
Local is: en_AU, Currency Symbol is: AUD
Local is: sr
Local is: pt
Local is: uk
Local is: es_SV, Currency Symbol is: SVC
Local is: ru_RU, Currency Symbol is: RUB
Local is: sr_ME, Currency Symbol is: EUR
Local is: sq
Local is: be_BY, Currency Symbol is: BYR
Local is: bg_BG, Currency Symbol is: BGN
Local is: in
Local is: mt_MT, Currency Symbol is: EUR
Local is: es_PY, Currency Symbol is: PYG
Local is: sl
Local is: fr_FR, Currency Symbol is: EUR
Local is: cs_CZ, Currency Symbol is: CZK
Local is: it_CH, Currency Symbol is: CHF
Local is: ro_RO, Currency Symbol is: RON
Local is: es_PR, Currency Symbol is: $
Local is: en_CA, Currency Symbol is: CAD
Local is: de_DE, Currency Symbol is: EUR
Local is: ga
Local is: de_LU, Currency Symbol is: EUR
Local is: de
Local is: es_AR, Currency Symbol is: ARS
Local is: sk
Local is: ms_MY, Currency Symbol is: MYR
Local is: hr_HR, Currency Symbol is: HRK
Local is: en_SG, Currency Symbol is: SGD
Local is: da
Local is: mt
Local is: pl
Local is: tr
Local is: el
Local is: ms
Local is: sv_SE, Currency Symbol is: SEK
Local is: da_DK, Currency Symbol is: DKK
Local is: es_HN, Currency Symbol is: HNL


Thanks




Related Tutorials/Questions & Answers:
Currency Symbol problem
Currency Symbol problem  Hi All, My Server side code... Symbol is: PEN Local is: en Local is: es_PA, Currency Symbol is: PAB Local is: sr_BA, Currency Symbol is: BAM Local is: mk Local is: es_GT, Currency Symbol
currency symbols in excel
currency symbols in excel  How to add a currency symbol in Excel sheet? Please guide me
Advertisements
currency converter
currency converter  hi i have encountered a problem while creating a pdf file in jsp.... my problem is i want commas for the currency which is diplayed in the pdf file... i'm using sybase, stored procedure for the front end
currency conversion
currency conversion   hi frds.. I wan jsp code to convert currency in different formats??... if u know plz plz plz post it   Please visit the following link: http://www.roseindia.net/tutorials/I18N/currency
javascript regex validate currency
javascript regex validate currency  How to validate currency in JavaScript?   <html> <head> <title>Currency validation... validate() { var currency = document.getElementById("currency").value
currency - Java Beginners
currency  helo guys can you share me a code about Currency... Mexican pesos sample input: ENTER TYPE OF CURRENCY:(so the user must choose a currency if dollars,swiss francs,euro dollars or mexican pesos)sample I input
Currency Converter in PHP - PHP
Currency Converter in PHP  Can anyone give me an idea on how to convert US dollar, Rupees, euro and yen to pounds
Java Currency Converter
Java Currency Converter   Hi I was wondering if someone could help me write a program to convert Pounds into Euro's. The program should prompt the user to input the number of pounds and output the number of Euros
currency - Java Beginners
currency  helo guys can you share me a "JAVAcode" about Currency...=9.815 Mexican pesos sample input: ENTER TYPE OF CURRENCY:(so the user must choose a currency if dollars,swiss francs,euro dollars or mexican pesos)sample I
Java array in currency converter
Java array in currency converter  Hi all, My sister is trying to teach me java. She's in school for programming and I'm not but I am just trying... not have any programming experience. Right now I am working on this currency
Why not use Double or Float to represent currency?
Why not use Double or Float to represent currency?  Why not use Double or Float to represent currency
Currency Format Example
Currency Format Example       This Example shows you how to format currency according to the locale. In the code given below we are formatting Currency according to the locale. Methods
cannot find symbol method nextchar()??
cannot find symbol method nextchar()??  import java.util.Scanner; public class Calc5{ public static void main(String args[]){ Scanner obj = new Scanner(System.in); System.out.println("please enter
Formatting and Parsing Locale-Specific Currency
Formatting and Parsing Locale-Specific Currency In this section, you will learn how to format and parse the locale specific currency. Through the formatting... are going to format the number into locale specific currency using NumberFormat class
Symbol Substitution
Symbol Substitution            In this example , we are going... values which will  converted it into symbol. For this we just convert
how to write greater than symbol in a file using java
how to write greater than symbol in a file using java  Hello I want to write < and > symbol in a file but its coming like > and < Please...   Hi Thanks for your reply Actually the problem is I'm trying to read
JSP cannot find symbol error - JSP-Servlet
JSP cannot find symbol error  Suppose-- we created 'a.jsp' in which we make a database connection... how to retrieve 'new' here... If I want to access the 'new' string within the form what should i do???  
How to make a loading symbol
How to make a loading symbol Learn here to create your own loading symbol that show the loading process in the website. New File: Take a new document. Draw a Circle: Draw a circle with this "f20b27" color by using
equal symbol expected in jsp - JSP-Servlet
equal symbol expected in jsp   Hi frndz i am using following code to upload a file. <% Connection con=null; PreparedStatement pstatement... error org.apache.jasper.JasperException: /upload_page.jsp(2,26) equal symbol
Java error cannot find symbol
Java error cannot find symbol In this section you will learn about "cannot find symbol" in java. Java cannot find symbol is a type of error occurs... the variable in use its trying to refer, then it will give a error cannot find symbol
How to design a question message symbol
How to design a question message symbol Let's see how to make a question message symbol, you can make it by this example. Draw a circle.... Your will get it. Inset symbol: Choose Horizontal type tool (T
Java error cannot find symbol
“cannot find symbol”. The reason behind cannot find symbol error... the java error cannot find symbol. In this example a class name 'cannot find symbol' is used. int variable “w” and “x” with respective
How to insert a symbol on the stone
How to insert a symbol on the stone If you are not able to insert a symbol on the any object, you should come to this example to learn... symbol shape. It is your done here. Look
Java error cannot find symbol
Java error cannot find symbol       The java error cannot find symbol occurred when a Compiler... that help you in understanding java error cannot made symbol. For this we have
cannot find symbol class array queue--plzz somebody help..
cannot find symbol class array queue--plzz somebody help..  import java.util.*; public class Test { public static void main(String[] args) { ArrayQueue<String> q = new ArrayQueue<String>(6); System.out.println
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project... is text and all others are of currency data type. If i enter 0 or null value in currency column and then try to retrieve data using my servlet coding
java script to replace words starting and ending with tild(~) symbol in a text area with the word highlighted yellow.
java script to replace words starting and ending with tild(~) symbol in a text area with the word highlighted yellow.  Hi, I have an issue... to enter appropriate text for the portion preceded and succeded with tild(~) symbol
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql..."); ^ DBPhoneLookup.java:27: cannot find symbol symbol : method...=con.createStatement(); ^ i am confused what is the problem
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, like thanks n regards himanshu
Problem with loginbean.jsp
Problem with loginbean.jsp  http://www.roseindia.net/jsp/loginbean.shtml - I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this? Also in this example how
problem on strings
problem on strings  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this with out using StringBuffer concept. Thanks in advanace
problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other
Problem with cookies
Problem with cookies  Hello All, i need jsp code for RememberMe module of login. i am facing problem with cookies. so please if any one could guide me please help and provide mme the exact code.   Please visit
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
Oracle9i Problem
Oracle9i Problem  Hi I have a problem in Oracle9i .I have... the table what i created .But after closing the SQL+ ,the problem started.When i... .....;.it is saying no rows are selected.Why the problem arised in not getting the data that i
URL problem
URL problem  Hi. I have created a webpage for my project website. in that i have used frameset to split the page. Now if i click any link in the page its navigating to the another page. but the problem is here in the url its
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
JScrollBar Problem...
JScrollBar Problem...  Hello Sir/mam, Can i know how to use JScrollBar to JFrame without adding any JPanel to it.. i want to add JScrollBar Directly to JFrame... Please Provide me Simple Example so i can understand
problem with session.invalidate()
problem with session.invalidate()  i stuck by a line with "session.invalidate()", after user logout also by pressing the back button of the browser user is still able to navigate to his home page and able to view the session
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check
Skyline Problem
is the line tracing the largest y value from any rectangle in S The Problem: Write.... Your method should solve the problem three different ways; each solution
 

 

 

DMCA.com