Java 8 optional time part not working

后端 未结 3 2034
终归单人心
终归单人心 2021-02-08 05:28

I am trying to create date time format for optional time part currently I implemented this

import java.time.*;
import java.time.format.DateTimeFormatter;
import j         


        
3条回答
  •  我寻月下人不归
    2021-02-08 06:07

    I think what you want is DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss[.SSS][.S]'Z'")

    Basically it's saying to first check for the long-form of 2+ fraction-of-second digits, otherwise if that optional field is not present, check for the optional field of a single fraction-of-second digit specified by [.S]

提交回复
热议问题