2013-04-12 21 views
-2

我想將看起來像SQL時間戳的字符串轉換爲實際的時間戳。我怎樣才能做到這一點?我的字符串看起來像這樣。如何將從鍵盤給出的字符串轉換爲時間戳,然後將其與時間戳進行比較時間戳

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 
    System.out.print("Please enter StartTime (YYYY-MM-DD HH:MM:SS): "); 

    String StartTime = null; 

    try { 
     StartTime = reader.readLine(); 

    } catch (IOException e) { 
     e.printStackTrace(); 
    } 

然後,我想我database..Can做類似的東西,從一個SQL比較這時間戳,與時間戳?

在此先感謝!

回答

0

您可以通過Simplay使用。根據文檔類SimpleDateFormat

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.

相關問題