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);
}
}

运行结果:
[2013/08/09 05:54:32.578]
[2013/09/09 17:54:32.625]

Java输出当前的日期(年月日时分秒毫秒)的更多相关文章

  1. 年月日时分秒毫秒+随机数getSerialNum

    package com.creditharmony.apporveadapter.core.utils; import java.io.ByteArrayInputStream; import jav ...

  2. C语言获取字符年月日时分秒毫秒

    概述 本文演示环境: Windows10 使用C语言获取年月日时分秒毫秒, 代码 #include <iostream> #include <string> #include ...

  3. Asp.net(C#)年月日时分秒毫秒

    年月日时分秒毫秒格式:yyyyMMddHHmmssfff

  4. [置顶] java得到前一个月的年月日时分秒

    import java.util.Calendar; /** * 得到前一个月的年月日时分秒 * @author Mr.hu * 2013-6-28上午12:00:35 * Class Explain ...

  5. java日期格式(年月日时分秒毫秒)

    package test.remote.tools.combine; import java.text.SimpleDateFormat; import java.util.Calendar; imp ...

  6. java 获取当前时间及年月日时分秒

    java代码如下: package test; import java.text.SimpleDateFormat; import java.util.Calendar; import java.ut ...

  7. c#.net 获取时间日期年月日时分秒生成自动文件名格式

    下面是日期和时间的各种方法,转换为字符串. 如果把输出的格式改下就可以做类似的文件名了,例如:2016010110101224356.doc  c#用DateTime.Now.ToString(&qu ...

  8. time.c 的Java实现(从timestamp计算年月日时分秒等数值)

    time.c的Java实现 public class GMT { public static final int EPOCH_YEAR = 1970; public static final int[ ...

  9. c#.net 获取时间日期年月日时分秒格式

    今天写代码发现两个比较不错的分享下:1.DateTime.ParseExact很多时候我们获取的时间是数字形式表示的,好比20140127134015.927856,通过这个方法DateTime.Pa ...

随机推荐

  1. 列表标题栏添加CheckBox(自定义HanderView的时候实现)

    前段时间项目上的要求,要实现一个列表(见下图1).类似网页上的列表,可以通过选中标题栏的复选框,实现全选或者全不选的功能.但是看了很久,都没看到Qt哪个方法可以实现在标题栏添加控件. 图1 要实现这样 ...

  2. xpath的文本获取

    xpath中tidyText()获取标签下所有文本, text()本级文本, allText()各级所有文本.

  3. 基于visual Studio2013解决面试题之1503最大公约数最小公倍数

     题目

  4. hdu5338 ZZX and Permutations

    hdu5338 ZZX and Permutations 非原创,来自多校题解 不是自己写的,惭愧ing…… 留着以后自己参考…… lower_bound {1,2,4,5} 询问 2,返回的是 2 ...

  5. 执行shell脚本提示“syntax error near unexpected token for((i=0;i&lt;$length;i++))”

    sh脚本例如以下: #!/usr/bin/env bash county="3 4 5 6 7 8 9 10 11 12 16 29 39 44 53 62 72 84 97 115 128 ...

  6. 我是小白之<%%>用法

    下面知识都是摘录自网络 <%=   %>输出,等价于Response.Write()<%%>  写代码<%-- --%>注释. <% %>跟其它serv ...

  7. 解决Xcode 7编译错误:does not contain bitcode

    连接地址:http://jingyan.baidu.com/article/8065f87f96cf462331249801.html 好不容易更新到Xcode 7.0.1,重新编译代码,报错: do ...

  8. 实现浏览器遗漏的原件 jQuery.selectCheckbox

    工作中遇到了一个下拉需要实现checkbox的效果,如下图 或许网上已经有实现了,但简单的功能自己实现就好了, 结构 <div class="form-control-wrap&quo ...

  9. SQL注入(一)普通型注入

    既然说了从头开始,先从注入开始吧,先来温习一下之前会的一些注入. PHP注入 0x01: 判断是否存在注入: '   报错 ' and 1=1   正确 ' and 1=2   错误 0x01: or ...

  10. axure制作圆形组件——axure制作技巧

    Axure本身是没有直接提供圆形组件的,所以很多朋友在微博上问,如何使用axure制作圆形,难道都要找美工-- Axure没有提供圆形组件,但是它提供了一个万能组件--矩形组件,只要有矩形组件,我们就 ...