Opposite of adding minutes to a java date, this example shows how to subtract minutes from a date using java's Calendar.add, java 8 date time api, joda’s DateTime.minusMinutes and apache commons DateUtils.addMinutes. In each of the examples below, we will set a date that represents new years day or January 1st. Then we will subtract 1 minute to return a date that reperesents new years eve or December 31st.
Straight up Java
Output
Java 8 Date and Time API
Java 8 LocalDateTime.minusMinutes will return a copy of the LocalDateTime with the specified number of minutes subtracted.
Output
Joda Time
Joda DateTime.minusMinutes will return a copy the DateTime minus the specified number of minutes.
Output
Apache Commons
Apache commons DateUtils.addMinutes will adds a number of minutes, in this case a negative number of minutes, to the date returning a new object.