Java 在三星galaxy 5中将当前时间转换为utc格式

Java 在三星galaxy 5中将当前时间转换为utc格式,java,time,utc,Java,Time,Utc,我想在发布消息时将当前手机时间转换为UTC格式。我的代码在三星galaxy 5中不起作用。在三星,当前时间不转换。下面是我的代码 SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdfDateTime.setTimeZone(TimeZone.getTimeZone("UTC")); String newtime = sdfDateTime.format(new Date(System.cur

我想在发布消息时将当前手机时间转换为UTC格式。我的代码在三星galaxy 5中不起作用。在三星,当前时间不转换。下面是我的代码

SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdfDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
String newtime = sdfDateTime.format(new Date(System.currentTimeMillis()));

@Sujith:我已经格式化了您的代码,并删除了代码开头的美元符号,假设它是复制/粘贴或格式化错误。可能是重复的