zoukankan      html  css  js  c++  java
  • 格式化日期显示为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);
    			
    	}
    
    }
    
  • 相关阅读:
    2018 dnc .NET Core、.NET开发的大型网站列表、各大公司.NET职位精选,C#王者归来
    下载docker镜像报错,dial tcp x.x.x.x:443: connect: connection refused
    SpringMVC
    MyBatis操作数据库——增删改查
    MyBatis——Mapper配置并查询数据
    MyBatis工程搭建
    测试IOC&DI
    SpringAOP测试
    Spring连接Mysql
    Spring 工程搭建
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3290026.html
Copyright © 2011-2022 走看看