package test.remote.tools.combine; import java.text.SimpleDateFormat; import
java.util.Calendar;import java.util.Date; import java.util.GregorianCalendar;
public class TestOutDate { public static void main(String[] args) { //method 1
Calendar nowtime =new GregorianCalendar(); String strDateTime
="["+String.format("%04d", nowtime.get(Calendar.YEAR))+"/"+ String.format(
"%02d", nowtime.get(Calendar.MONTH))+"/" + String.format("%02d",
nowtime.get(Calendar.DATE))+" " + String.format("%02d",
nowtime.get(Calendar.HOUR))+":" + String.format("%02d",
nowtime.get(Calendar.MINUTE))+":" + String.format("%02d",
nowtime.get(Calendar.SECOND))+"." + String.format("%03d",
nowtime.get(Calendar.MILLISECOND))+"]"; System.out.println(strDateTime); //
method 2 String msg=""; Date date = new Date(); SimpleDateFormat sdf = new
SimpleDateFormat("YYYY/MM/dd HH:mm:ss.SSS"); msg+="["+sdf.format(date)+"]";
System.out.println(msg); } }
 运行结果:

[2018/04/25 02:51:33.379]

[2018/05/25 14:51:33.393]

技术
©2019-2020 Toolsou All rights reserved,
Java开发2020年最新常见面试题整理【Spring源码分析】42-@Conditional详解element-ui踩坑记录神仙面试宝典你有了吗?半月看完25大专题,居然斩获阿里P8offer使用css样式设计一个简单的html登陆界面XCTF攻防世界web新手练习_ 9_command_executionJS中的解构赋值的详解与具体用途Python Web 框架elementui 穿梭框 el-transfer 展示列表内容文字过长ConcurrentHashMap实现原理及源码解析