Pages

2011-01-12

Get UTC Time stamp from epoch

      String UTC_TIMEZONE = "UTC"; 
      String m_DateFormat = "yyyy-MM-dd HH:mm:ss";
      public String getUtcTimeStampFromEpoch(long epoch) {
           
             SimpleDateFormat df = new java.text.SimpleDateFormat(m_DateFormat);
             df.setTimeZone(TimeZone.getTimeZone(UTC_TIMEZONE));
             return     df.format(new java.util.Date(epoch * 1000));
      }



That's it!

No comments:

Post a Comment