Created
October 31, 2017 13:29
-
-
Save Ameausoone/486064e9601c78e2c0aa581cc3cc5510 to your computer and use it in GitHub Desktop.
Java Date transformation java8 java.util.Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public java.util.Date fromAAAAMMDDStringTojava_util_Date_withJava8(){ | |
Stirng dateStr = "20171031"; | |
TemporalAccessor temporalAccessor = java.time.format.DateTimeFormatter.BASIC_ISO_DATE.parse(dateStr); | |
LocalDate localDate = java.time.LocalDate.from(temporalAccessor); | |
return Date.from(localDate.atStartOfDay(systemDefault()).toInstant()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment