public static String getTimeZoneDatetime(String time, String timeZone) { if (StringUtil.isEmpty(time) || StringUtil.isEmpty(timeZone)) { return ""; } try { DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd\'T\'hh:ss:mm.SSS\'Z\'"); sdf.setTimeZone(TimeZone.getTimeZone(timeZone)); return sdf.format(new Date(Long.parseLong(time))); } catch (NumberFormatException e) { return time; } }
public static long getDateTime(String dateTime) { if (StringUtil.isEmpty(dateTime)) { return 0; } DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return sdf.parse(dateTime).getTime(); } catch (ParseException e) { return 0; } }