我如何转换newValue2
为,Integer
因为我将在 if 语句中使用它?
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