Skip to content

Commit 28de015

Browse files
authored
first commit
0 parents  commit 28de015

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

SimpleDateFormatExamples.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.text.SimpleDateFormat;
2+
import java.util.Date;
3+
4+
public class SimpleDateFormatExamples {
5+
6+
public static void main(String[] args) {
7+
Date date = new Date();
8+
9+
//01.23.2020 22:14:32
10+
SimpleDateFormat sdf1 = new SimpleDateFormat("MM.d.yyyy HH:mm:ss");
11+
System.out.println(sdf1.format(date));
12+
13+
//÷åòâåðã 23 ÿíâàðÿ 2020 22:17:54
14+
SimpleDateFormat sdf2 = new SimpleDateFormat("EEEEE DD MMMMM yyyy HH:mm:ss");
15+
System.out.println(sdf2.format(date));
16+
17+
//×ò, 23 ÿíâ 2020 22:20:46 MSK
18+
SimpleDateFormat sdf3 = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z");
19+
System.out.println(sdf3.format(date));
20+
21+
//23 ÿíâàðÿ 2020 Moscow Standard Time
22+
SimpleDateFormat sdf4 = new SimpleDateFormat("dd MMMM yyyy zzzz");
23+
System.out.println(sdf4.format(date));
24+
25+
//01.23.2020 10:27 PM (Moscow Standard Time)
26+
SimpleDateFormat sdf5 = new SimpleDateFormat("MM.d.yyyy h:mm a (zzzz)");
27+
System.out.println(sdf5.format(date));
28+
29+
//22:30:33 (+03:00)
30+
SimpleDateFormat sdf6 = new SimpleDateFormat("HH:mm:ss (XXX)");
31+
System.out.println(sdf6.format(date));
32+
33+
//2020.01.23 í.ý. â 22:33:45 MSK
34+
SimpleDateFormat sdf7 = new SimpleDateFormat("yyyy.MM.dd G 'â' HH:mm:ss z");
35+
System.out.println(sdf7.format(date));
36+
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)