-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDates.java
More file actions
56 lines (47 loc) · 1.86 KB
/
Dates.java
File metadata and controls
56 lines (47 loc) · 1.86 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
// LSE-LocFmtDates/Dates.java
//taha burak sahin pjatk
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import javax.swing.JOptionPane;
public class Dates {
public static void main(String[] args) {
SimpleDateFormat dinp =
(SimpleDateFormat)DateFormat.getDateInstance();
dinp.applyPattern("y M d");
SimpleDateFormat doEn =
(SimpleDateFormat)DateFormat.getDateInstance(
DateFormat.SHORT,Locale.US);
SimpleDateFormat doFr =
(SimpleDateFormat)DateFormat.getDateInstance(
DateFormat.SHORT,Locale.FRANCE);
SimpleDateFormat doPl =
(SimpleDateFormat)DateFormat.getDateInstance(
DateFormat.SHORT,new Locale("pl"));
SimpleDateFormat doGr =
(SimpleDateFormat)DateFormat.getDateInstance(
DateFormat.FULL,new Locale("el","GR"));
doEn.applyPattern("EEEE, d 'of' MMMM',' yyyy G");
doFr.applyPattern("yyyy'/'MM'/'dd' ('EEEE')'");
doPl.applyPattern("'Ten dzie\u0144 to 'EEEE',' d "+
"MMMM yyyy' r.'");
while (true) {
String s = JOptionPane.showInputDialog(null,
"Enter a date as \'y m d\'",
"Enter a date",
JOptionPane.QUESTION_MESSAGE);
if (s == null || s.length() == 0) break;
Date d = dinp.parse(s,new ParsePosition(0));
JOptionPane.showMessageDialog(null,
"<html>" + doEn.format(d)+
"<br />" + doFr.format(d)+
"<br />" + doPl.format(d)+
"<br />" + doGr.format(d),
"Date",JOptionPane.INFORMATION_MESSAGE);
}
System.exit(0);
}
}