I need to change de format of a date to UTC format.
File fi开发者_运维百科le = new File();
...
file.lastModified();
I need to convert the lastModified date of a file in UTC format.
String lv_dateFormateInUTC=""; //Will hold the final converted date      
SimpleDateFormat lv_formatter = new SimpleDateFormat(); 
lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));  
lv_dateFormateInUTC = lv_formatter.format(lv_localDate); 
Something like that...!!
Quite simply:
Date date = new Date(file.lastModified())
This works because the long value returned by File.lastModified() represents the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970) as stated in the Javadoc. And the same is true of java.util.Date. So they are both in UTC/GMT already. When a date is converted to a string such as via Date.toString() or a DateFormat object, it's typically expressed in the local timezone, but the long value it stores is timezone-agnostic.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论