How to get the current date and time

后端 未结 10 508
无人共我
无人共我 2020-11-29 16:59

How do I get the current date and time in Java?

I am looking for something that is equivalent to DateTime.Now from C#.

10条回答
  •  粉色の甜心
    2020-11-29 17:38

    import java.util.Date;   
    Date now = new Date();
    

    Note that the Date object is mutable and if you want to do anything sophisticated, use jodatime.

提交回复
热议问题