date - Converting from Milliseconds to UTC Time in Java -


i'm trying convert millisecond time (milliseconds since jan 1 1970) time in utc in java. i've seen lot of other questions utilize simpledateformat change timezone, i'm not sure how time simpledateformat, far i've figured out how string or date.

so instance if initial time value 1427723278405, can mon mar 30 09:48:45 edt using either string date = new simpledateformat("mmm dd hh:mm:ss z yyyy", locale.english).format(new date (epoch)); or date d = new date(epoch); whenever try change simpledateformat this encounter issues because i'm not sure of way convert date or string dateformat , change timezone.

if has way appreciate help, thanks!

try below..

package com.example;  import java.text.simpledateformat; import java.util.date; import java.util.timezone;  public class testclient {  /**  * @param args  */ public static void main(string[] args) {     long time = 1427723278405l;     simpledateformat sdf = new simpledateformat();     sdf.settimezone(timezone.gettimezone("utc"));     system.out.println(sdf.format(new date(time)));  }  } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -