date-time icon indicating copy to clipboard operation
date-time copied to clipboard

Parse from String with custom Pattern

Open hantsy opened this issue 3 years ago • 3 comments

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")),

hantsy avatar Dec 26 '20 12:12 hantsy

That's just https://www.php.net/manual/en/datetime.createfromformat.php

jurchiks avatar Sep 27 '21 21:09 jurchiks

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))

hantsy avatar Sep 28 '21 04:09 hantsy

Relates to https://github.com/brick/date-time/issues/3

solodkiy avatar Apr 10 '22 09:04 solodkiy