import java.text.SimpleDateFormat;import java.util.Date;public class Test{public static void main (String[] args){Date date = new Date();SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");System.out.println("时间为:" +sdf.format(date));}}
这样可以输出格式为yyyyMMddHHmmss格式的时间字符串格式
