格式化日期显示为2013-08-29 02:47:03的形式

格式化日期显示为2013-08-29 02:47:03的形式,方法如下:

 

import java.text.SimpleDateFormat;

import java.util.Date;



public class timeFormat {



	/**

	 * Author jinhoward

	 * Date:2013-08-29

	 */

	public static void main(String[] args) {

	    SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  

	    Date date = new Date(System.currentTimeMillis());  

            //格式化的效果:例如2013-08-29 02:47:03

	    String time = sfd.format(date);

            System.out.println("格式化后的日期显示效果为:"+time);

			

	}



}


格式化日期显示为2013年08月29日 02:47:03的形式,方法如下:

 

import java.text.SimpleDateFormat;

import java.util.Date;



public class timeFormat {



	/**

	 * Author jinhoward

	 * Date:2013-08-29

	 */

	public static void main(String[] args) {

	    SimpleDateFormat sfd = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");  

	    Date date = new Date(System.currentTimeMillis());  

	    String time = sfd.format(date);//格式化的效果:2013年08月29日 05:56:09

		System.out.println("格式化后的日期显示效果为:"+time);

			

	}



}

 

 

import java.text.SimpleDateFormat;

import java.util.Date;



public class timeFormat {



	/**

	 * Author jinhoward

	 * Date:2013-08-29

	 */

	public static void main(String[] args) {

	    SimpleDateFormat sfd = new SimpleDateFormat("yyyy年MM月dd日 hh时mm分ss秒");  

	    Date date = new Date(System.currentTimeMillis());  

	    String time = sfd.format(date);//格式化的效果:2013年08月29日 05时59分36秒

		System.out.println("格式化后的日期显示效果为:"+time);

			

	}



}

 

 

 

你可能感兴趣的:(格式化)