File tree Expand file tree Collapse file tree
src/ru/javawebinar/basejava Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package ru .javawebinar .basejava ;
2+
3+ import java .text .SimpleDateFormat ;
4+ import java .time .LocalDate ;
5+ import java .time .LocalDateTime ;
6+ import java .time .LocalTime ;
7+ import java .time .format .DateTimeFormatter ;
8+ import java .util .Calendar ;
9+ import java .util .Date ;
10+ import java .util .TimeZone ;
11+
12+ /**
13+ * gkislin
14+ * 20.07.2016
15+ */
16+ public class MainDate {
17+ public static void main (String [] args ) {
18+ long start = System .currentTimeMillis ();
19+ Date date = new Date ();
20+ System .out .println (date );
21+ System .out .println (System .currentTimeMillis () - start );
22+ Calendar cal = Calendar .getInstance ();
23+ cal .setTimeZone (TimeZone .getTimeZone ("America/Los_Angeles" ));
24+ System .out .println (cal .getTime ());
25+
26+ LocalDate ld = LocalDate .now ();
27+ LocalTime lt = LocalTime .now ();
28+ LocalDateTime ldt = LocalDateTime .of (ld , lt );
29+ System .out .println (ldt );
30+
31+
32+ SimpleDateFormat sdf = new SimpleDateFormat ("YY/MM/dd" );
33+ System .out .println (sdf .format (date ));
34+
35+ DateTimeFormatter dtf = DateTimeFormatter .ofPattern ("YY/MM/dd" );
36+ System .out .println (dtf .format (ldt ));
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ package ru .javawebinar .basejava .util ;
2+
3+ import java .time .LocalDate ;
4+ import java .time .Month ;
5+
6+ /**
7+ * gkislin
8+ * 20.07.2016
9+ */
10+ public class DateUtil {
11+ public static LocalDate of (int year , Month month ) {
12+ return LocalDate .of (year , month , 1 );
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments