public String changTime(String cTime, int addM) {
int index = cTime.indexOf(":");
int hInt = Integer.parseInt(cTime.substring(0, index));
int mInt = Integer.parseInt(cTime.substring(index + 1, cTime.length()));
int min = mInt + addM;
int hour = hInt;
int round;
if (min < 0) {
round = (min - 59) / 60;
} else {
round = min / 60;
} if ((min) >= 60) {
while (min >= 60) {
min = min - 60;
}
} else if ((min < 0)) {
while (min < 0) {
min = min + 60;
}
}
hour = hour + round;
if (hour > 24) {
hour = hour - 24;
} else if (hour < 0) {
hour = hour + 24;
}
System.out.println(hour + ":" + min);
return hour + ":" + min;
}

解决方案 »

  1.   

    SimpleDateFormat timeFormat=new SimpleDateFormat("hh:mm");
          System.out.println(timeFormat.format(date).toString());
          date.setMinutes(date.getMinutes()+10);
          String newDate=timeFormat.format(date).toString();
          System.out.println(newDate);
      

  2.   

    blackcourser(be stronger……) :
    SimpleDateFormat timeFormat=new SimpleDateFormat("hh:mm");
          System.out.println(timeFormat.format(date).toString());
          date.setMinutes(date.getMinutes()+10);
          String newDate=timeFormat.format(date).toString();
          System.out.println(newDate);
    这个不错
      

  3.   

    SimpleDateFormat timeFormat=new SimpleDateFormat("hh:mm");date.setMinutes(date.getMinutes()+10);
      

  4.   

    Date#getMinutes() is deprecated.
    使用 date.getTime() + (10 * 60) 来代替
      

  5.   

    blackcourser(be stronger……) 不错的说