Run the applet below on a system that has Euro support (say, Windows NT 4.0 with the patches from http://www.microsoft.com/windows/euro.asp). Click the "Next Locale" button until you get to Italy. You'll see that the value 1.23 is shown as just <Euro> 1. It should be <Euro> 1.23. Probably a currency format is used that was intended for Italian Lire, but the Euro is valuable enough to warrant decimals.
// Test : Euro Currency Test.
// Project: JDK 1.1.7 maintenance testing
// Author : ###@###.###
// Date : 15 Jul 98
// Purpose: To test the euro currency.
import java.awt.*;
import java.applet.Applet;
import java.lang.*;
import java.text.NumberFormat;
import java.util.Locale;
public class EuroTest extends Applet {
static int MaxPartialLocales = 13;
static String[][] PartialLocale = {
{ "de", "AT", "Austria" },
{ "de", "DE", "Germany" },
{ "de", "LU", "Luxembourg (German)" },
{ "en", "IE", "Ireland" },
{ "es", "ES", "Spain" },
{ "fi", "FI", "Finland" },
{ "fr", "BE", "Belgium (French)" },
{ "fr", "FR", "France" },
{ "fr", "LU", "Luxembourg (French)" },
{ "it", "IT", "Italy" },
{ "nl", "BE", "Belgium (Dutch)" },
{ "nl", "NL", "Netherlands" },
{ "pt", "PT", "Portugal" }
};
int CurrentLocale = 0;
boolean PrintTested = false;
Label lab0 = new Label("Country Tested:", Label.CENTER);
Label lab1 = new Label("Locale Name:", Label.CENTER);
Label lab2 = new Label("Formatted Number:", Label.CENTER);
Label lab3 = new Label("Euro Currency Symbol:", Label.CENTER);
Label lab4 = new Label("Euro Currency Input:", Label.CENTER);
Label lab5 = new Label("Type the Euro Symbol in the Input field",Label.CENTER);
Label lab6 = new Label("Solaris=[AltGraph+4] Windows=[Alt+0128]",Label.CENTER);
Label labCountry = new Label("", Label.CENTER);
Label labLocale = new Label("", Label.CENTER);
Label labFormat = new Label("", Label.CENTER);
Label labEuro = new Label("", Label.CENTER);
TextField InputEuro = new TextField();
Button prev = new Button(" Previous Locale ");
Button next = new Button(" Next Locale ");
Button quit = new Button(" Exit Test ");
Button print = new Button(" Print Euro Symbol ");
public void init()
{
Panel mainPanel = new Panel();
add(mainPanel);
mainPanel.setLayout(new GridLayout(8,2,10,10));
// setFont(new Font("Times New Roman", Font.BOLD, 15));
mainPanel.add(lab0);
mainPanel.add(labCountry);
mainPanel.add(lab1);
mainPanel.add(labLocale);
mainPanel.add(lab2);
mainPanel.add(labFormat);
mainPanel.add(lab3);
mainPanel.add(labEuro);
lab5.setFont(new Font("Times New Roman", Font.PLAIN, 10));
mainPanel.add(lab5);
lab6.setFont(new Font("Times New Roman", Font.PLAIN, 10));
mainPanel.add(lab6);
mainPanel.add(lab4);
mainPanel.add(InputEuro);
mainPanel.add(prev);
mainPanel.add(next);
// mainPanel.add(print);
// mainPanel.add(quit);
pict();
}
public boolean action(Event e, Object arg)
{
boolean doPict = true;
if (e.target == next) {
CurrentLocale++;
if (CurrentLocale >= MaxPartialLocales) {
CurrentLocale = MaxPartialLocales - 1;
doPict = false;
}
}
if (e.target == prev) {
CurrentLocale--;
if (CurrentLocale < 0) {
CurrentLocale = 0;
doPict = false;
}
}
if (e.target == print) {
doPict = false;
if (!PrintTested) {
PrintTested = true;
print.setForeground(Color.white);
doTestPrint();
}
}
if (e.target == quit) System.exit(-1);
if (doPict) pict();
return true;
}
public void pict()
{
Locale myLocale;
myLocale = new Locale(PartialLocale[CurrentLocale][0], PartialLocale[CurrentLocale][1], "EURO");
// Locale.setDefault(myLocale);
NumberFormat format = NumberFormat.getCurrencyInstance(myLocale);
String stringWithEuro = format.format(1.23);
// The string should have the euro symbol in it.
// Display in the Applet window.
labCountry.setText(PartialLocale[CurrentLocale][2]);
labLocale.setText(myLocale.toString());
labFormat.setText(stringWithEuro);
labEuro.setText("\u20ac");
// Clean Text Field
InputEuro.setText("");
// Display in the system prompt.
System.out.println("\nCountry Tested : " + PartialLocale[CurrentLocale][2]);
System.out.println("Locale Name : " + myLocale.toString());
System.out.println("Formatted Number : " + stringWithEuro);
System.out.println("Euro Currency Symbol : \u20ac");
prev.setForeground(Color.black);
next.setForeground(Color.black);
if (CurrentLocale == 0) prev.setForeground(Color.white);
if (CurrentLocale == MaxPartialLocales - 1) next.setForeground(Color.white);
}
public void doTestPrint()
{
}
}
sandy.labrasca@eng 1999-01-12
Added DMT in the program management field.
This will be in the 1.1.7_05 pre-release notes.
// Test : Euro Currency Test.
// Project: JDK 1.1.7 maintenance testing
// Author : ###@###.###
// Date : 15 Jul 98
// Purpose: To test the euro currency.
import java.awt.*;
import java.applet.Applet;
import java.lang.*;
import java.text.NumberFormat;
import java.util.Locale;
public class EuroTest extends Applet {
static int MaxPartialLocales = 13;
static String[][] PartialLocale = {
{ "de", "AT", "Austria" },
{ "de", "DE", "Germany" },
{ "de", "LU", "Luxembourg (German)" },
{ "en", "IE", "Ireland" },
{ "es", "ES", "Spain" },
{ "fi", "FI", "Finland" },
{ "fr", "BE", "Belgium (French)" },
{ "fr", "FR", "France" },
{ "fr", "LU", "Luxembourg (French)" },
{ "it", "IT", "Italy" },
{ "nl", "BE", "Belgium (Dutch)" },
{ "nl", "NL", "Netherlands" },
{ "pt", "PT", "Portugal" }
};
int CurrentLocale = 0;
boolean PrintTested = false;
Label lab0 = new Label("Country Tested:", Label.CENTER);
Label lab1 = new Label("Locale Name:", Label.CENTER);
Label lab2 = new Label("Formatted Number:", Label.CENTER);
Label lab3 = new Label("Euro Currency Symbol:", Label.CENTER);
Label lab4 = new Label("Euro Currency Input:", Label.CENTER);
Label lab5 = new Label("Type the Euro Symbol in the Input field",Label.CENTER);
Label lab6 = new Label("Solaris=[AltGraph+4] Windows=[Alt+0128]",Label.CENTER);
Label labCountry = new Label("", Label.CENTER);
Label labLocale = new Label("", Label.CENTER);
Label labFormat = new Label("", Label.CENTER);
Label labEuro = new Label("", Label.CENTER);
TextField InputEuro = new TextField();
Button prev = new Button(" Previous Locale ");
Button next = new Button(" Next Locale ");
Button quit = new Button(" Exit Test ");
Button print = new Button(" Print Euro Symbol ");
public void init()
{
Panel mainPanel = new Panel();
add(mainPanel);
mainPanel.setLayout(new GridLayout(8,2,10,10));
// setFont(new Font("Times New Roman", Font.BOLD, 15));
mainPanel.add(lab0);
mainPanel.add(labCountry);
mainPanel.add(lab1);
mainPanel.add(labLocale);
mainPanel.add(lab2);
mainPanel.add(labFormat);
mainPanel.add(lab3);
mainPanel.add(labEuro);
lab5.setFont(new Font("Times New Roman", Font.PLAIN, 10));
mainPanel.add(lab5);
lab6.setFont(new Font("Times New Roman", Font.PLAIN, 10));
mainPanel.add(lab6);
mainPanel.add(lab4);
mainPanel.add(InputEuro);
mainPanel.add(prev);
mainPanel.add(next);
// mainPanel.add(print);
// mainPanel.add(quit);
pict();
}
public boolean action(Event e, Object arg)
{
boolean doPict = true;
if (e.target == next) {
CurrentLocale++;
if (CurrentLocale >= MaxPartialLocales) {
CurrentLocale = MaxPartialLocales - 1;
doPict = false;
}
}
if (e.target == prev) {
CurrentLocale--;
if (CurrentLocale < 0) {
CurrentLocale = 0;
doPict = false;
}
}
if (e.target == print) {
doPict = false;
if (!PrintTested) {
PrintTested = true;
print.setForeground(Color.white);
doTestPrint();
}
}
if (e.target == quit) System.exit(-1);
if (doPict) pict();
return true;
}
public void pict()
{
Locale myLocale;
myLocale = new Locale(PartialLocale[CurrentLocale][0], PartialLocale[CurrentLocale][1], "EURO");
// Locale.setDefault(myLocale);
NumberFormat format = NumberFormat.getCurrencyInstance(myLocale);
String stringWithEuro = format.format(1.23);
// The string should have the euro symbol in it.
// Display in the Applet window.
labCountry.setText(PartialLocale[CurrentLocale][2]);
labLocale.setText(myLocale.toString());
labFormat.setText(stringWithEuro);
labEuro.setText("\u20ac");
// Clean Text Field
InputEuro.setText("");
// Display in the system prompt.
System.out.println("\nCountry Tested : " + PartialLocale[CurrentLocale][2]);
System.out.println("Locale Name : " + myLocale.toString());
System.out.println("Formatted Number : " + stringWithEuro);
System.out.println("Euro Currency Symbol : \u20ac");
prev.setForeground(Color.black);
next.setForeground(Color.black);
if (CurrentLocale == 0) prev.setForeground(Color.white);
if (CurrentLocale == MaxPartialLocales - 1) next.setForeground(Color.white);
}
public void doTestPrint()
{
}
}
sandy.labrasca@eng 1999-01-12
Added DMT in the program management field.
This will be in the 1.1.7_05 pre-release notes.
- duplicates
-
JDK-4181994 Incorrect it_IT_EURO locale definition
-
- Closed
-