如何解析三个DateTIme

时间:2016-12-17 15:55:03

标签: android java-time threetenbp

我正在尝试解析这个DateTime:

<html class = "full" lang="en">
        <head>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
            <link rel="stylesheet" href="style.css" type="text/css">
         </head>
        <div class = "row">
            <div class = "col-md-3"></div>
            <div class = "col-md-6 frameHolder">
                <div id="frame1" class = "quizFrame quizFrame1">
                    <p>Click Start Game below to begin the quiz</p>
                    <button onclick="Run();">Start Game</button>
                </div>
            </div>
            <div class = "col-md-3"></div>
        </div>
    </html>

但是我收到了这个错误:

DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
                    .appendPattern("dd/MM/yyyy hh:mm:ss")
                    .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
                    .parseDefaulting(ChronoField.MILLI_OF_SECOND, 0)
                    .toFormatter();

            String ultimaAtualizacaoTexto = "17/12/2016 01:41:43";

            LocalDateTime ultimaAtualizacaoDateTime =
                    LocalDateTime.parse(ultimaAtualizacaoTexto, dateTimeFormatter);

我不确定发生了什么......它应该完全有效!

对此有何帮助?不管怎样,谢谢!

1 个答案:

答案 0 :(得分:1)

所以......我不得不将“dd / MM / yyyy hh:mm:ss”更改为“dd / MM / yyyy HH:mm:ss”

因为......仅在上午12点/下午时。 HH是24小时。