/** * @author : hzy * @param json * @param formatStyle * @return 取JSONObject中的时间以想要的格式 返回字符串 */ public static String getTimeByJT(JSONObject json, String formatStyle) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(formatStyle); if (!ObjectCensor.checkObjectIsNull(json)) { date.setTime(Long.parseLong(StringUtil.getJSONObjectKeyVal(json, "time"))); String dateStr = sdf.format(date); return dateStr; } else { return null; } }
/** * @author : tiankang * @param json * @return 取JSONObject中的时间 */ public static Timestamp getTimestampByJT(JSONObject json) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (!ObjectCensor.checkObjectIsNull(json)) { date.setTime(Long.parseLong(StringUtil.getJSONObjectKeyVal(json, "time"))); String dateStr = sdf.format(date); Timestamp sta = Timestamp.valueOf(dateStr); return sta; } else { return null; } }