标签:取字符串 min EDA val 知识点 截取 bst str substr
//以下测试代码主要是针对数据库中时间字段的简单求和实现,采用了“遍历”,“String与int的相互转换”,“截取字符串”等多个知识点。
public void queryBy(){
List<Course> courses = courseDao.queryBy(3);
System.out.println("queryBy="+courses);
int minSum =0;
int sSum=0;
for(int i=0;i<courses.size();i++){
Course course = courses.get(i);
String courseLength = course.getCourseLength();
String minuteStr = courseLength.substring(1, 3);
Integer minute = Integer.valueOf(minuteStr);
System.out.println(minute);
minSum+=minute;
String substring = courseLength.substring(4, 6);
Integer s = Integer.valueOf(substring);
System.out.println(s);
sSum+=s;
}
System.out.println("minSum="+minSum); System.out.println("sSum="+sSum);
}
标签:取字符串 min EDA val 知识点 截取 bst str substr
原文地址:https://www.cnblogs.com/WTBK/p/9398626.html