Custom date format cannot be parsed. (Java)

后端 未结 4 961
遇见更好的自我
遇见更好的自我 2020-12-11 16:53

I have to use a custom date format in Java. It contains microseconds although Java doesn\'t provide support for microseconds. Because of that I filled the time pattern with

4条回答
  •  情书的邮戳
    2020-12-11 17:20

    Add a '' around the zeros, like so: "yyyy-MM-dd-HH.mm.ss.SSS'000'"

    Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. "''" represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.

提交回复
热议问题