-1

if ステートメントで使用するので、newValue2どのように変換すればよいですか?Integer

try {
    toDate=format2.parse(string1);
    java.util.Date newValue= new SimpleDateFormat(oldf).parse(string1);
     String newValue2 = new SimpleDateFormat(newf).format(newValue);

     int qwe = Integer.parseInt(newValue2);

     if (qwe < 8){

            String fixtime = ("08:00 PM");


            DateTime dateTime3 = dtf.parseDateTime(fixtime.toString());
            Period period = new Period(dateTime3, dateTime2);

            PeriodFormatter formatter = new PeriodFormatterBuilder()

            .appendHours().appendSuffix(".")
            .appendMinutes().appendSuffix("")
            .toFormatter();

            String elapsed = formatter.print(period);

            table_4.setValueAt(elapsed,0,3);
                        }

    } catch (ParseException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }

ここでの出力を確認するためだけに変更してみnewValue2ます:

try {
    toDate=format2.parse(string1);
    java.util.Date newValue= new SimpleDateFormat(oldf).parse(string1);
    String newValue2 = new SimpleDateFormat(newf).format(newValue);

    System.out.println (newValue2);

//  int qwe = Integer.parseInt(newValue2);

//  System.out.println(qwe);

    } catch (ParseException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }

出力するデータの例:

07:00 AM 


System.out.println(newValue2);

07.00 0
4

2 に答える 2

0

あなたのコードに基づいて、からnewValue2の値を含む文字列ですSimpleDateFormat.format()。の値を示していただけますnewfか? すべての数字になる場合は、現在行っていることで十分です。

于 2013-06-06T07:16:39.920 に答える