//写成工具类
public class TimeUtils {
// 将long类型转为时间戳
public static String longToDate(long lo) {
Date date = new Date(lo);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sd.format(date);
}
}
//用的时候直接调用工具类:比如
long time = item.getConsumerTime();//得到long数值
String s = TimeUtils.longToDate( time );//将long转换成时间戳
helper.setText( R.id.tv_wallet_time,s);//赋值
博客给出了一个Java时间工具类的示例,定义了TimeUtils类,使用时可直接调用该工具类。

683

被折叠的 条评论
为什么被折叠?



