Java UNIX时间转换代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

public static String toLocalTime(String unix) {
    Long timestamp = Long.parseLong(unix) * 1000;
    String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date(timestamp));
    return date;
}

public static String toUnixTime(String local){
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String unix = "";
    try {
        unix = df.parse(local).getTime() + "";
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return unix;
}