我有一个日期值,我想使用它写入文件
fw = new BufferedWriter(new FileWriter(root + "/log.txt"));
fw.newLine();
fw.write("," + "server timestamp " + "," + " Timestamp");
fw.newLine();
fw.write( " ,");
fw.write(dateString + "," + currentTimeStamp);
但每次 dateString 和 currentTimeStamp 为空,通过 toast 我可以看到 dateString 和 currentTimeStamp 不为空,但我无法通过 FileWritter 编写它们。
这是 dateString 的代码
SimpleDateFormat formatter = new SimpleDateFormat("HH-mm-ss_SSS");
dateString = formatter.format(returnTime);
currentTimeStamp = formatter.format(new Date());