java格林时间和标准时间之间相互转换

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


public class Time {

	public static void main(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");  
        String datetime = sdf.format(Long.parseLong("1323842302")*1000);  
        datetime = sdf.format(1325433638000L);  //毫秒转为字符串
        System.out.println(datetime); 
        b();
        
	}
	
	public static void b() {
		DateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
		try {
			Date myDate = format.parse("2012/01/02 00:00:38");
			System.out.println(myDate.toString());
			System.out.println(myDate.getTime()); //标准字符串转为毫秒(格林时间)
		} catch (ParseException e1) {
			e1.printStackTrace();
		}
	}

}

你可能感兴趣的:(java)