我有两行要在我的主应用程序屏幕上打印。我试图将它们设置为一个变量以在主屏幕上打印。我放入Java文件的是:
public class TimeZoneConverter {
public void main(String args[]) {
//Date will return local time in Java
Date localTime = new Date();
//creating DateFormat for converting time from local timezone to GMT
SimpleDateFormat converter = new SimpleDateFormat("dd/MM/yyyy:HH:mm:ss");
//getting GMT timezone, you can get any timezone e.g. UTC
converter.setTimeZone(TimeZone.getTimeZone("GMT"));
String1 = System.out.println("local time : " + localTime);;
String2 = System.out.println("time in GMT : " + converter.format(localTime));
}
}
}
它说字符串无法解析为变量。我将如何尝试将它放到我的主屏幕上?