Skip to content

Instantly share code, notes, and snippets.

@Ameausoone
Created October 31, 2017 13:29
Show Gist options
  • Save Ameausoone/486064e9601c78e2c0aa581cc3cc5510 to your computer and use it in GitHub Desktop.
Save Ameausoone/486064e9601c78e2c0aa581cc3cc5510 to your computer and use it in GitHub Desktop.
Java Date transformation java8 java.util.Date
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