자바 유 닉 스 와 정상 시간 변환

1688 단어
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class test {

	/**
	 * @param args
	 */
	
	public static void main(String[] args) {
		//SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" );
		 

		String time="1997-09-06";// :            
		Date date=new Date();
		try {
		System.out.println(	new SimpleDateFormat( "yyyy-MM-dd" ).parse(time).getTime());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 

	//	System.out.println("Format To times:"+date.getTime());
		
		Timestamp unixTime;
		try {
			unixTime = new Timestamp(new SimpleDateFormat( "yyyy-MM-dd" ).parse(time).getTime());
			System.out.println(unixTime);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//Timestamp unixTime = 		new Timestamp();
	

	}
	
	/*
	public static void main(String[] args) {
		   SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" );
		    

		  String time="2013-03-27";// :            
		   Date date=new Date();
		   try {
		    date = format.parse(time);
		   } catch (ParseException e) {
		    // TODO Auto-generated catch block
		    e.printStackTrace();
		   }
		    

		  System.out.println("Format To times:"+date.getTime());
		   String string="13644864" +
		   		"";
		   Timestamp unixTime =   new Timestamp((long)Integer.parseInt(string));
		   //Timestamp unixTime =   new Timestamp();
		   System.out.println(unixTime);
		 
		 }

*/
}




좋은 웹페이지 즐겨찾기