将String转化为Long,并将Long转化为Date


package org.ljh.test.javaee;

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

public class StringToLongToDate {
	
	public static String parseTime(String s){
		
		//将字符串转化为Long类型
		Long timeLong = Long.parseLong(s);
		//将Long类型转化为Date
		Date date = new Date(timeLong);
		
		//将Date类型格式化
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = sdf.format(date);
		return dateString;
		
	}
	
	public static void main(String[] args){
		System.out.println(parseTime("5223456789236"));
	}

}

输出结果:2135-07-12 00:13:09

posted @ 2014-06-30 16:23  eagleGeek  阅读(218)  评论(0编辑  收藏  举报