DateTime dateTime= DateTime.now();

 2021-04-08 11:48:24.933164
更多详细信息可以通过SubString(0,19)截取

dateTime.toString().substring(0,19)

 2021-04-08 11:51:07 

 

或者是通过下面方法直接获取

dateTime.day
dateTime.month
dateTime.year
dateTime.hour
dateTime.minute
dateTime.second
dateTime.millisecond
dateTime.millisecondsSinceEpoch