Opposite of subtracting milliseconds from a java date, this example will show how to add milliseconds to a date using Calendar.add, java 8 date time api, joda DateTime.plusMillis and apache commons DateUtils.addMilliseconds. In the examples below, we will set a date that represents new years eve, December 31st, then add milliseconds to return a date representing new years day or January 1st.
Straight up Java
Output
Java 8 Date and Time API
Java 8 LocalDateTime.plus will return a copy of the LocalDateTime with the specified amount added, in this case ChronoField.MILLI_OF_DAY.
Output
Joda Time
Joda DateTime.plusMillis will return a copy the DateTime plus the specified number of milliseconds.
Output
Apache Commons
Apache commons DateUtils.addMilliseconds will adds a number of milliseconds to the date returning a new object.