這些知識點雖然很簡單,但在項目中會經常使用,記錄下來方便以後使用
、獲取系統時間
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);