数据重复而不是循环

时间:2015-05-05 08:53:20

标签: java loops

我无法遍历转换数据并为每列显示。

输出应该显示为每列转换的不同时间,而是显示每列的相同时间。

这是我的代码:

  String MS = "";
  String time = MS;

        //Converting date and time to milliseconds

    for (int t = 0; t < timeMS.length; t ++)
        {
            String strDate = timeMS[t];
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
            Date getDate = sdf.parse(strDate);
            getDate.getTime();
            MS = time + (getDate.getTime());
        }

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

                 String set2 = "";
                   {
                     if ( rs.getString("data2") != null )
                     set2 = rs.getString("data2");

                     String[] set3 = set2.split("<SPLIT>");

                for ( int i = 0 ; i <set3.length ; i ++ )
                    if ( dataGroup2.containsKey(set3 [i]) )
                        dataGroup2.get(set3 [i]).put(data1, MS);
                     }
            }   

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

                for ( String set3 : dataGroup2.keySet() )
                {
                    if ( dataGroup2.get(set3 ).containsKey(  set1.get(i)  ) )
                        dataGroup1.get(set3 ).append(MS +",");
                    else
                        dataGroup1.get(set3 ).append("0,");
                }
            }

当前输出

    tyu,ghj,bnm
qwe,123, 0,  0,
asd, 0, 123, 0,
zxc, 0,  0, 123,

所需的输出

    tyu,ghj,bnm
qwe,123, 0,  0,
asd, 0, 456, 0,
zxc, 0,  0, 789,

0 个答案:

没有答案