「Java入門」java.time.LocalTimeのサンプル

2017年12月21日

javaコード
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;

public class LocalDateTimeDemo {

public static void main(String[] args) {
// current
LocalDateTime localDateTime1 = LocalDateTime.now();
System.out.println(localDateTime1);

LocalDateTime localDateTime2 = LocalDateTime.of(2017, Month.JUNE, 21, 16, 12, 34);
System.out.println(localDateTime2);
// from a local date and a local time
LocalDate localDate1 = LocalDate.of(2017, 5, 10);
LocalTime localTime= LocalTime.of(16, 18, 41);
LocalDateTime localDateTime3 = LocalDateTime.of(localDate1, localTime);
System.out.println(localDateTime3);

}

}
結果
2017-12-21T01:50:30.022
2017-06-21T16:12:34
2017-05-10T16:18:41

Java

Posted by arkgame