Skip to content

Commit 41185be

Browse files
author
walf
committed
test
1 parent 3137733 commit 41185be

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package DateDemo;
2+
3+
import java.text.DateFormat;
4+
import java.text.SimpleDateFormat;
5+
import java.util.Calendar;
6+
import java.util.Date;
7+
8+
public class DateDemo {
9+
10+
public static void main(String[] args) {
11+
System.out.println("-----");
12+
DateFormat dfm = new SimpleDateFormat("yyyy-MM-DD HH:mm:ss");
13+
Date date = new Date();
14+
15+
String str = dfm.format(date);
16+
System.out.println(str);
17+
18+
19+
//Calendar日历类,add() set()get()
20+
21+
Calendar calendar = Calendar.getInstance();
22+
int year = calendar.get(Calendar.YEAR);
23+
System.out.println(year);
24+
25+
26+
}
27+
}

0 commit comments

Comments
 (0)