日期格式不一样

时间:2014-08-02 19:49:34

标签: java parsing date

好的,这就是问题所在:

Calendar date = Calendar.getInstance();
date.setTime(new Date());

File fileVIPC = new File("VIP members class list.txt");
Scanner scV = new Scanner(fileVIP);
scV.useDelimiter(",");

if(!fileVIPC.exists())
  fileVIPC.createNewFile();

Scanner newVIP = new Scanner(fileVIPC);
newVIP.useDelimiter(",");
SimpleDateFormat f = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Date rCDate;
String rCExpiryDate;
rCExpiryDate = scV.next();              
rCDate = f.parse(rCExpiryDate);

int dateInt = Integer.valueOf(date.get(Calendar.YEAR));
                    dateInt += 1;
                    date.set(Calendar.YEAR,dateInt);

                    dateInt = Integer.valueOf(date.get(Calendar.DAY_OF_MONTH));
                    dateInt -= 1;
                    date.set(Calendar.DAY_OF_MONTH,dateInt);

    date.set(Calendar.YEAR,dateInt);
    rCDate = date.getTime();
    bWriterRenewVIP.write(rCDate +",");

所以,当我写入我的txt文件时,结果就像这个Aug 02 03:23:28 SGT 3,我不知道为什么在我续约1年之后有3个,它应该显示2016或别的。你需要的任何附加代码告诉我。请帮助,谢谢!!

0 个答案:

没有答案