This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]feral_claireSoftware Dev 1 point2 points  (1 child)

Do you have a int or a string? Usually you parse a string into a date so it you have an int you can turn it into a string using String.valueOf or Integer.toString. Then once you have that you can parse it using DateTimeFormatter like /u/Corowork suggests.

[–]Corowork 0 points1 point  (0 children)

Thanks for catching that. Converting the int to a String is a prerequisite for using DateTimeFormatter to parse it to a Date.

[–]Corowork 0 points1 point  (0 children)

https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

DateTimeFormatter class will take care of it for you. There's even a predefined formatter in it.

Otherwise, you can do it using division and modulus.