java 日期格式SimpleDateFormat例子

来源:互联网 发布:企业oa软件 编辑:程序博客网 时间:2024/05/17 03:01

/*
 * Created on 2005-9-7
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author kun
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class DateDemo {
 private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 private static String dateStr;

 public static void main(String args[]){
 Date date=new Date();
 Date datelong=new Date("January 1, 1970, 00:00:00 GMT");
 dateStr=dateTimeFormat.format(date); 
 //System.out.println(dateStr);
 //System.out.println(datelong);
 //System.out.println(System.nanoTime());
 //System.out.println(System.currentTimeMillis());
 try{
 System.out.println(new DateDemo().clone().toString());
 }catch(CloneNotSupportedException r){
  r.printStackTrace();  
  }
 catch(Exception e){
  e.printStackTrace();
 }

 

 }
}

原创粉丝点击