-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocales.java
More file actions
56 lines (44 loc) · 1.64 KB
/
Locales.java
File metadata and controls
56 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// LRR-Locales/Locales.java
//taha burak sahin pjatk
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Date;
import javax.swing.JOptionPane;
public class Locales {
public static void main(String[] args) {
// all available locales
Locale[] allLocs = Locale.getAvailableLocales();
System.out.println("Available locales:");
for (Locale loc : allLocs)
System.out.println(loc);
System.out.println("\n");
Locale[] locs = {
Locale.getDefault(),
Locale.US, Locale.FRANCE,
new Locale("cs","CZ"),
new Locale("no","NO","NY"),
new Locale("Ar","KW"),
};
for (Locale loc : locs) info(loc);
System.exit(0);
}
static public void info(Locale loc) {
Locale def = Locale.getDefault();
Locale.setDefault(loc);
DateFormat df =
DateFormat.getDateInstance(DateFormat.FULL);
NumberFormat nf = NumberFormat.getInstance();
StringBuilder sb = new StringBuilder();
sb.append("<html>Locale: " + loc + " " +
loc.getDisplayCountry() + " (" +
loc.getDisplayCountry(Locale.US) +
")<br />");
sb.append("Date: "+df.format(new Date())+"<br />");
sb.append("Number: " + nf.format(987654.321));
JOptionPane.showMessageDialog(
null,sb.toString(),"Locale info",
JOptionPane.INFORMATION_MESSAGE);
Locale.setDefault(def);
}
}