获取系统时间及将时间戳转化为时间

来源:互联网 发布:7.1声道耳机推荐 知乎 编辑:程序博客网 时间:2024/05/16 08:05

这些知识点虽然很简单,但在项目中会经常使用,记录下来方便以后使用

、获取系统时间

public String getDateNow() {    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");    final String format = simpleDateFormat.format(new Date(System.currentTimeMillis()));    return format;}
//将时间戳转换成时间SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Long longTime = new Long(notifyList.get(position).get("createTime"));Date date = new Date(longTime);String createTime = simpleDateFormat.format(date);

0 0
原创粉丝点击