How to create DateTimeformatter with optional seconds arguments
问题 I am trying to create a DateTimeformatter to validate following date times: String date1 = "2017-07-06T17:25:28"; String date2 = "2017-07-06T17:25:28.1"; String date3 = "2017-07-06T17:25:28.12"; String date4 = "2017-07-06T17:25:28.123"; String date5 = "2017-07-06T17:25:28.1234"; String date6 = "2017-07-06T17:25:28.12345"; String date7 = "2017-07-06T17:25:28.123456"; String date8 = "2017-07-06T17:25:28."; I have tried the following date time formatter to validate above dates: public static