Calendar cal = Calendar.getInstance(); long currentTimeInMillis = System.currentTimeMillis(); cal.setTimeInMillis(currentTimeInMillis);
Calendar cal = Calendar.getInstance(); long millis = 1617638400000L; // 2021-04-06T00:00:00.000Z cal.setTimeInMillis(millis);These examples demonstrate how to set the time in a Calendar object using milliseconds. The package library for this class is java.util.