Go from java.util.Date to java.time.LocalDate?

3

I have a date on Date and I want to move it to LocalDate:

Date fechaAntigua = new Date();
LocalDate fechaNueva = new LocalDate();

fechaNueva = fechaAntigua ...?
    
asked by Oundroni 13.06.2016 в 15:18
source

3 answers

5

Try with:

Date fechaAntigua = new Date();
LocalDate fechaNueva = fechaAntigua.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

Extracted from OS: convert-java-util-date-to -java-time-localdate

    
answered by 13.06.2016 / 15:34
source
1

Can be obtained through the LocalDate class using toInstant () :

import java.time.LocalDate;
import java.time.ZoneId;
... 
...
Date input = new Date();
LocalDate date = input.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    
answered by 13.06.2016 в 17:11
0

Explanation of each library together with the functionality that each one fulfills within the program.

    
answered by 20.06.2016 в 06:28