我无法在Java中正确解析日期

时间:2016-09-01 00:16:01

标签: java parsing simpledateformat

我知道我必须使用SimpleDateFormat,但我无法解析所需格式的日期。

我从.txt文件输入的内容如下:  2015-09-01 00:10:21.863 这是我的代码。

public class RequestList { 
   private ArrayList<Request> reqList = new ArrayList<>(); 
   SimpleDateFormat reqDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 
   private Request r = new Request();

public ArrayList load_request_list(String filename)  throws Exception
{
    reqList.clear(); //Arraylist with every request from filename
    BufferedReader br =  new BufferedReader(new FileReader(filename));
    String ligne = br.readLine(); // first line read
    ligne = br.readLine(); //second line read
    String [] tab2 = ligne.trim().split(";");
    while(tab2 != null)
    {
        req.reception_time = reqDF.parse(tab2[3]); 
        ...
     }

在我的主要内容中,当我尝试读取req.reception_time时,我的输出是:

Tue Sep 01 00:15:28 EDT 2015

这是因为reception_time是作为日期构建的吗? 谢谢!

0 个答案:

没有答案
相关问题