date-time
date-time copied to clipboard
Parse from String with custom Pattern
In Java 8 DateTime, the parse
can accept a custom Pattern simply.
LocalDateTime.parse(fields[1].trim(), DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss")),
That's just https://www.php.net/manual/en/datetime.createfromformat.php
That's just https://www.php.net/manual/en/datetime.createfromformat.php
Currently I used the following statement to parse a string to LocalDateTime
, it looks a little tedious. Hope there is a method aligned to Java DateTime.
LocalDateTime::fromDateTime(DateTime::createFromFormat('d/m/Y H:i:s', $fromDate))
Relates to https://github.com/brick/date-time/issues/3