方式一:
Calendar calendar = Calendar.getInstance();
int offset = calendar.get(Calendar.ZONE_OFFSET);
calendar.add(Calendar.MILLISECOND, -offset);
Date date = calendar.getTime();
方式二:
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = calendar.getTime();
The second one gets the time in GMT time zone, and the first one gets the time before the current time zone. Use Date.format() to print and see the effect.