我要執行像如何解析Date formate?
該代碼會拋出異常後登錄系統 Process uptimeProc = Runtime.getRuntime().exec("net stats srv");
BufferedReader in = new BufferedReader(new inputStreamReader(uptimeProc.getInputStream()));
String line;
while ((line = in.readLine()) != null)
{
if(line.contains("Statistics since"))
{
SimpleDateFormat format = new SimpleDateFormat("'Statistics since' MM/dd/yyyy hh:mm:ss a");
//System.out.println("in ijj "+in.readLine());
Date boottime = format.parse(line);
System.out.println("Uptime="+uptime+""+boottime);
uptime = System.currentTimeMillis() - boottime.getTime();
break;
}
}
的&註銷時間
Exception in thread "main" java.text.ParseException: Unparseable date: "Statistics since 6/16/2014 10:08 AM"
at java.text.DateFormat.parse(DateFormat.java:337)
at programs.GetLoginTimeYaar.getSystemUptime(GetLoginTimeYaar.java:44)
at programs.GetLoginTimeYaar.main(GetLoginTimeYaar.java:14)
PLZ回覆
花費一些時間在閱讀[相關問題和解答](http://stackoverflow.com/search?q=ParseException [java]) –