-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleDateFormatTest.java
More file actions
34 lines (25 loc) · 926 Bytes
/
SimpleDateFormatTest.java
File metadata and controls
34 lines (25 loc) · 926 Bytes
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
package datereflection;
import java.text.SimpleDateFormat;
import java.util.Date;
public class SimpleDateFormatTest {
public static void main(String[] args) {
for (;;) {// Infinite Loop
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
String strDate = formatter.format(date);
System.out.println("DateFormat: MM/dd/yyyy : " + strDate);
formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
strDate = formatter.format(date);
System.out.println("DateFormat: dd-M-yyyy hh:mm:ss : " + strDate);
formatter = new SimpleDateFormat("dd MMMM yyyy");
strDate = formatter.format(date);
System.out.println("DateFormat: dd MMMM yyyy : " + strDate);
try { // Only continue loop after 2 second
Thread.sleep(2000);
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}