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(); 功能:创建一个日期时间对象 ...
随机推荐
- Sublime Text 3中SublimeLinter的使用
关于Sublime Text 2中的SublimeLinter的使用网上多如牛毛,基本上不会遇到什么问题,简单的讲一下关于Sublime Text 3中遇到的问题: 1.通过package cont ...
- Linux解决安装包无法找到问题Unable to locate package rar
1:问题 在默认安装的Linux中有时候会找不到需要安装的软件包,那就需要更新了 例如在执行apt-get install xx的时候就报错了 E: Unable to locate package ...
- BigDecimal 的幂次方运算
public static void main(String[] args){ BigDecimal bg1, bg2; bg1 = new BigDecimal("200000.45&qu ...
- [Functional Programming] Running though a serial number prediction functions for tagging, pairing the result into object
Let's we have some prediction functions, for each prediction function has a corresponding tag: const ...
- 浅谈压缩感知(十六):感知矩阵之RIP
在压缩感知中,总是看到"矩阵满足RIP"之类的字眼,没错,这是一个压缩感知绕不开的术语,有限等距性质(Restricted Isometry Property, RIP). 注意: ...
- conEmu的使用笔记
1.如何让conEmu成为windows的默认控制台程序? 解决:选中settings > Integration > Default Term里的Force ConEmu as defa ...
- CSS3实现的苹果网站搜索框效果
在线演示 本地下载 用CSS3相关属性生成的动态搜索框效果.
- iOS开发点滴 - 关闭键盘
有时候系统显示的键盘会挡住视图中某些重要的控件,这个时候当用户按下换行键,就应该取消UITextField对象的第一响应(First Responder)状态而关闭键盘. 1. 首先,视图控制器必须遵 ...
- jquery.cookie.js结合asp.net实现最近浏览记录
一.html代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
- Centos7中修改Hostname的方法
一.Centos7中修改的方法: hostnamectl set-hostname <new hostname> 说明:centOS 7 里面修改hostname的方式有所改变,修改/et ...