java日期格式(年月日时分秒毫秒)
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]
java日期格式(年月日时分秒毫秒)的更多相关文章
- Java输出当前的日期(年月日时分秒毫秒)
package test.remote.tools.combine; import java.text.SimpleDateFormat; import java.util.Calendar; imp ...
- 年月日时分秒毫秒+随机数getSerialNum
package com.creditharmony.apporveadapter.core.utils; import java.io.ByteArrayInputStream; import jav ...
- Asp.net(C#)年月日时分秒毫秒
年月日时分秒毫秒格式:yyyyMMddHHmmssfff
- C语言获取字符年月日时分秒毫秒
概述 本文演示环境: Windows10 使用C语言获取年月日时分秒毫秒, 代码 #include <iostream> #include <string> #include ...
- java createSQLQuery().list()返回日期格式没有时分秒的解决方法
方法一 将Oracel数据库对应表中“收单时间的字段”receive_sheet_time,由原来的Date类型改为timestamp 然后,在java程序中,由 (java.util.timesta ...
- java Date获取 年月日时分秒
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- Android Calendar获取年月日时分秒毫秒
开始使用new Date()测试,并用通过date.getMonth(),和date.getDay()获取,不过后来发现这两个访求是jdk1.1版本的,现在已经不用了,而且结果也不正确. ; int ...
- mysql获取表中日期的年月日时分秒
SELECT year(callTheRollTime) from schedule_account 获取年 SELECT month(callTheRollTime) from schedule_a ...
- JavaScript中的内置对象-8--4.date对象中-获取,设置日期时间的方法; 获取,设置年月日时分秒及星期的方法;
学习目标 1.掌握创建日期对象的方法 2.掌握date对象中获取日期时间的方法 3.掌握date对象中设置日期时间的方法 如何创建一个日期对象 语法:new Date(); 功能:创建一个日期时间对象 ...
随机推荐
- springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
方法1: application.yml mybatis-plus: configuration: jdbc-type-for-null: 'null' #注意:单引号 方法2: 查看mp-start ...
- 必须记住的 30 类 CSS 选择器
大概大家读知道`id`,`class`以及`descendant`选择器,并且整体都在使用它们,那么你正在错误拥有更大级别的灵活性的选择方式.这篇文章里面提到的大部分选择器都是在CSS3标准下的,所以 ...
- Oracle中rownum用法警示
今天调试代码,发现分页查询时使用Oracle中rownum的between......and用法的bug,特此总结: 参考资料:http://blog.csdn.net/lg312200538/art ...
- [ Laravel 5.5 文档 ] 官方扩展包 —— 全文搜索解决方案:Laravel Scout
简介 Laravel Scout 为 Eloquent 模型全文搜索实现提供了简单的.基于驱动的解决方案.通过使用模型观察者,Scout 会自动同步更新模型记录的索引. 目前,Scout 通过 Alg ...
- ASP.NET压力测试
本文导读:对于直接面对互联网用户的WEB应用,在开发设计的时候必须格外小心,因为谁也不知道在单位时间内WEB程序访问和运行的速度.所以,在程序设计完成以后,最后针对程序进行一些严格的甚至是苛刻的测试, ...
- linux下性能分析命令[总结]
1.前言 在linux下开发程序,为了追求高性能,经常需要测试程序的性能,包括cpu.内存.io.网络等等使用情况.liunx下提供了众多命令方便查看各种资源的使用情况.经常用的有ps.top.fre ...
- 基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线!
基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线! https://www.sohu.com/a/168292858_747818 https://github.com/ ...
- IIS 7.5: HOW TO ENABLE TLS 1.1 AND TLS 1.2
In IIS 7.5, which is installed on Windows 2008 R2 servers, only SSL 3.0 and TLS 1.0 are enabled for ...
- 转:C++操作mysql方法总结(1)
原文:http://www.cnblogs.com/joeblackzqq/p/4332945.html C++通过mysql的c api和通过mysql的Connector C++ 1.1.3操作m ...
- 【Python】安装geopy
C:\Users\horn1\Desktop\python\49-geo>pip install geopy Collecting geopy Retrying (Retry(total=4, ...