java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Generate Java Time Random Date

Open patou opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. With a java 8+ project we must convert Date to LocalDate, LocalDateTime, ...

Describe the solution you'd like The faker should return java time object instead of java Date.

LocalDate date = faker.localDate().past(1, TimeUnit.DAYS);

Describe alternatives you've considered The actual code is :

LocalDate date = faker.date().past(1, TimeUnit.DAYS).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

Additional context The lib must change to be build with java 8 SDK (the java 6 support is end since december 2018)

patou avatar Nov 09 '20 09:11 patou

Maybe using java.time.temporal.ChronoUnit would be a better fit. It would at least offer more possibilities, but the added complexity might be a non-starter.

faker.localDate().past(6, ChronoUnit.MONTHS);

Jeff-Walker avatar Dec 01 '20 21:12 Jeff-Walker

Our group are interested in this issue, we will try to fix it. ---- SE_Sustech

Juan-Chen45 avatar Mar 11 '21 14:03 Juan-Chen45

I'd like to pull request for this issue.

CharlotteE67 avatar Apr 24 '21 13:04 CharlotteE67

#624

CharlotteE67 avatar Apr 24 '21 13:04 CharlotteE67

Is this issue resolved?

AlexTamulaitis avatar Oct 31 '21 17:10 AlexTamulaitis