无法循环访问不同的数据

时间:2015-04-23 06:59:26

标签: java

我无法遍历我的数据库中的timeList来输出我需要的不同时间。它们只循环遍历第一个,并为我需要的每个输出显示相同的数据。如果我要关闭转换的for循环,我会在输出语句中显示它时出现问题。

String[] timeMinute = timeList .split("<SPLIT>");

            for (int t = 0; t <timeMinute.length; t ++)
            {
                String strDate = timeList;
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
                Date getDate = sdf.parse(strDate);
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(getDate);
                int noOfHours = calendar.get(Calendar.HOUR_OF_DAY);
                int noOfMinutes = calendar.get(Calendar.MINUTE);
                int totalMinutes = noOfHours * 60 + noOfMinutes;

            while ( rs.next() )
            {   
                String RTD= rs.getString("RTD");
                if ( !trd1.contains( RTD) )
                    trd1.add(RTD);

                String admissionCOUNT = "";

                if ( rs.getString("jae") != null )
                    admission  = rs.getString("jae");

                String[] admissionCOUNT = admission.split("<SPLIT>");

                for ( int i = 0 ; i <gateNo.length ; i ++ )
                {
                    if ( kpm.containsKey(gateNo[i]) )
                        kpm.get(admissionCOUNT [i]).put(RTD, + totalMinutes);
                }
            }

            for ( int i = 0 ; i < .size(); i++)
            {
                stringWriter.append( trd1.get(i)  + ",");

                for ( String admissionCOUNT : kpm.keySet() )
                {
                    if ( kpm.get(admissionCOUNT ).containsKey(trd1.get(i)  ) )
                        MSO.get(admissionCOUNT ).append(totalMinutes +",");
                    else
                        MSO.get(admissionCOUNT ).append("0,");
                }

            }

当前输出示例 -

data1,0,56,0

data2,56,0,0

data3,56,0,0

data4,0,0,56

欲望输出示例 -

data1,0,87,0

data2,56,0,0

data3,43,0,0

data4,0,0,91

编辑:

for ( String egm : .keySet() )
                resultString += System.getProperty("line.separator") + gate + "," + MSO.get(egm).toString();

0 个答案:

没有答案