Fixed wrong time parsing (#10523)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
0c36650179
commit
7dad6ea973
@ -12,8 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.tr064.internal.soap;
|
package org.openhab.binding.tr064.internal.soap;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.time.LocalDateTime;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -28,7 +30,7 @@ import org.openhab.binding.tr064.internal.dto.additions.Call;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class CallListEntry {
|
public class CallListEntry {
|
||||||
private static final SimpleDateFormat DATE_FORMAT_PARSER = new SimpleDateFormat("dd.MM.yy hh:mm");
|
private static final DateTimeFormatter DATE_FORMAT_PARSER = DateTimeFormatter.ofPattern("dd.MM.yy HH:mm");
|
||||||
public @Nullable String localNumber;
|
public @Nullable String localNumber;
|
||||||
public @Nullable String remoteNumber;
|
public @Nullable String remoteNumber;
|
||||||
public @Nullable Date date;
|
public @Nullable Date date;
|
||||||
@ -37,8 +39,9 @@ public class CallListEntry {
|
|||||||
|
|
||||||
public CallListEntry(Call call) {
|
public CallListEntry(Call call) {
|
||||||
try {
|
try {
|
||||||
date = DATE_FORMAT_PARSER.parse(call.getDate());
|
date = Date.from(
|
||||||
} catch (ParseException e) {
|
LocalDateTime.parse(call.getDate(), DATE_FORMAT_PARSER).atZone(ZoneId.systemDefault()).toInstant());
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
// ignore parsing error
|
// ignore parsing error
|
||||||
date = null;
|
date = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user