SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));//设置TimeZone为上海时间
Date now = new Date();//获取本地时间
try {
now=sdf.parse(sdf.format(now));//将本地时间转换为转换时间为东八区
} catch (ParseException e) {
e.printStackTrace();
}
安卓将本地时间转换为东八区时间
最新推荐文章于 2022-12-02 01:45:00 发布