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;
}
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;
}
解决方案 »
- 怎么利用javadoc,将注释文档提取为一个HTML文件,并用Web浏览器观看。
- java调用linux命令执行不成功
- java程序难题
- 关于Json的生成
- 本程序的功能是把一个字符串作为参数传递给程序,与程序中的字符串比较,如果相等输出“Equal”,否则输出“Unequal”,比如运行程序:jav
- 有关JAVA中使用SQL语句后返回记录集的问题!
- so简单的问题~~~~~
- 文件名含“ $ ”的文件是临时文件吗?用jad *.class时它不反编译“ $ ”文件?
- 求APPLET树型导航菜单的源码
- 急!急急!在JAVA中,当你按下一个按钮后,怎样才能打开另一个窗口?
- 一行数据库链接代码,请大家帮忙看看
- 散分一百,救命啊,在线等!
System.out.println(timeFormat.format(date).toString());
date.setMinutes(date.getMinutes()+10);
String newDate=timeFormat.format(date).toString();
System.out.println(newDate);
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);
这个不错
使用 date.getTime() + (10 * 60) 来代替