import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
System.out.println(transferLongToDate("MM/dd/yyyy HH:mm:ss",1476758669802l));
System.out.println(transferLongToDate("MM/dd/yyyy HH:mm:ss",1476758669803l));
}
/**
* * 把毫秒转化成日期
* * @param dateFormat(日期格式,例如:MM/ dd/yyyy HH:mm:ss)
* * @param millSec(毫秒数)
* * @return
*
* */
private static String transferLongToDate(String dateFormat,Long millSec){
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
Date date= new Date(millSec);
return sdf.format(date);
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
System.out.println(transferLongToDate("MM/dd/yyyy HH:mm:ss",1476758669802l));
System.out.println(transferLongToDate("MM/dd/yyyy HH:mm:ss",1476758669803l));
}
/**
* * 把毫秒转化成日期
* * @param dateFormat(日期格式,例如:MM/ dd/yyyy HH:mm:ss)
* * @param millSec(毫秒数)
* * @return
*
* */
private static String transferLongToDate(String dateFormat,Long millSec){
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
Date date= new Date(millSec);
return sdf.format(date);
}
}