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,
Django个人博客搭建教程---时间分类归档你不知道的鸿蒙——HarmonyOS记录一次游戏私服getshell过程mysql联合索引详解百度网盘偷偷更新,终于实现免费不限速了! 全球第一免费开源ERP Odoo Ubuntu最佳开发环境独家首发分享uniapp页面传值总结Android中获取当前正在显示的Activity实例SQL Server 数据库词汇表Python垃圾回收与内存泄露