欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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]

相關文章

最新評論