I'm trying to set the time to epoch date time in java. how can I do this? so that I could get year months days etc out of the epoch date time.
use new Date(0L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); System.out.println(sdf.format(new Date(0L)));
Take care of your timezone cause it will change depends on what you have by default.
In java 8 you can use the new
You have this constant