java获取时间

本文章用于记录简单的获取时间,主要是怕自己忘记了。(也方便新手)
 
//将某个日期以固定(自定义)格式转化成字符串
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒ms分");


Date time = new Date();//时间对象


String date= sdf.format(time);//data就是获取到的时间

猜你喜欢

转载自blog.csdn.net/qq_38026437/article/details/78930796