java打印时间精确到毫秒

时间:2021-02-22 05:17:24
package net.floodlightcontroller.conflict;

import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat; public class OutputLog {
public static void outPutLogToDeaktop(String fileName, String info) {
File out_file = new File("/home/wangyong/Desktop/" + fileName);
try {
FileWriter fw = new FileWriter(out_file, out_file.exists());
fw.write( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())
+ " : " + info + "\n" );
fw.close();
} catch (IOException e) {
System.out.println("FileWriter IOException!");
e.printStackTrace();
} }
}