Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to parse following date time string

2018-01-30T23:59:59.000

I am not able to understand which standard format it is like UTC or ISO_8601

while parsing in the following manner:

SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD'T'HH:MM:SS:MS");
        Date date = null;
        try {
            date = sdf.parse("2018-01-30T23:59:59.000");
        } catch (ParseException e) {
            e.printStackTrace();
        }

But It is throwing following exception:

java.text.ParseException: Unparseable date: "2018-01-30T23:59:59.000"

Any help is appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
605 views
Welcome To Ask or Share your Answers For Others

1 Answer

See the doc of SimpleDateFormat and try this:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...