Example #1
0
 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;
   }
 }
Example #2
0
 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;
   }
 }