最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java輸出系統(tǒng)當(dāng)前的日期(年月日時(shí)分秒毫秒)

 更新時(shí)間:2013年09月10日 16:23:23   作者:  
當(dāng)前的日期輸出的方法有很多,本文為大家介紹下在java中是如何實(shí)現(xiàn)輸出年月日時(shí)分秒毫秒的,感興趣的朋友不妨參考下
復(fù)制代碼 代碼如下:

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

運(yùn)行結(jié)果:
[2013/08/09 05:54:32.578]
[2013/09/09 17:54:32.625]

相關(guān)文章

最新評(píng)論

紫阳县| 柏乡县| 北票市| 六安市| 天气| 大洼县| 广河县| 齐齐哈尔市| 浦东新区| 社会| 利津县| 大理市| 黄山市| 松潘县| 道孚县| 加查县| 宜丰县| 东至县| 德惠市| 双辽市| 遂昌县| 育儿| 招远市| 吉安市| 泸溪县| 东山县| 沂源县| 望都县| 保定市| 青州市| 体育| 科技| 成安县| 汽车| 北票市| 施秉县| 当涂县| 静安区| 金门县| 民乐县| 阳朔县|