JAVA Long String类型之间的转换

Long 转date
Date result = new Date(param*1000);
Long 转String
String result = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(param* 1000));

String转date
Date result = new DateTime(param).toDate();
String转Long
Long result = Long.valueOf(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(param).getTime() / 1000);


Date转String
String result = new SimpleDateFormat("yyyyMMddHHmmss").format(param);
String result = new DateTime(param).toString("yyyy-MM-dd HH:mm:ss");
Date转Long
Long result = Long.valueOf(param.getTime() / 1000);

猜你喜欢

转载自www.cnblogs.com/missmeng/p/10276100.html