Android Convert Unix Time to GMT time

前端 未结 2 485
粉色の甜心
粉色の甜心 2021-01-21 15:01

I\'m having trouble in converting a unix time into GMT.

I have the following code, but I would like to know how to vice versa it.

    public static Str         


        
相关标签:
2条回答
  • 2021-01-21 15:46

    Try this

    Date d = new Date(1308670980000L);
    SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy,HH:mm");
    f.setTimeZone(TimeZone.getTimeZone("GMT"));
    String s = f.format(d);
    
    0 讨论(0)
  • 2021-01-21 15:55

    long unixTime = unixTime;

    java.util.Date GMTTime=new java.util.Date(unixTime);

    System.out.println("GMTTime:: "+ GMTTime);

    0 讨论(0)
提交回复
热议问题