Here you can find the source of minusMinutes(String s, long minutes)
static public String minusMinutes(String s, long minutes) throws Exception
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); you may import java.text.SimpleDateFormat; import java.util.Date; public class Main { static public String minusMinutes(String s, long minutes) throws Exception { if (!s.contains(" ")) throw new Exception(); Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(s); //minus x minutes long time = date.getTime() - (minutes * 10000L); //reset time to 1 minute ago date.setTime(time);/*from w w w. jav a 2s. c o m*/ //create formatter SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); //return date in original format return sf.format(date); } }