Java: Get current Date and Time from Server not System clock

前端 未结 4 1228
天涯浪人
天涯浪人 2020-11-27 08:05

In my Java program, I need to create an instance of the current moment in time. I use

Date date = new Date();

This gives me the current dat

4条回答
  •  感动是毒
    2020-11-27 08:28

    You can use the following code:

            LocalDate localDate = LocalDate.now();
            int year = localDate.getYear();
            int month = localDate.getMonthValue();
            int date = localDate.getDayOfMonth();
    

提交回复
热议问题