int a=comboBox.getSelectedIndex();//获得选中时间的下标
String b=new String();
b="GMT+"+a;//设置时区格式
TimeZone shiqu = TimeZone.getTimeZone(b);//获得对应时区
Calendar calendar = Calendar.getInstance();
Calendar LATime = new GregorianCalendar(shiqu);//导入获得的时区时间
LATime.setTimeInMillis(calendar.getTimeInMillis());//时间获取到秒
int year = LATime.get(Calendar.YEAR);
int month = LATime.get(Calendar.MONTH)+1;
int date = LATime.get(Calendar.DATE);
int hour=LATime.get(Calendar.HOUR_OF_DAY)+1;
int minute=LATime.get(Calendar.MINUTE);
int s=LATime.get(Calendar.SECOND);
String next=year+"年"+month+"月"+date+"日"+hour+"时"+minute+"分"+s+"秒";//初始化时间格式
showtime.setText(next);//lable框中输出时间
String b2=new String();
b2=comboBox.getSelectedItem().toString();//得到选中的文本
lblNewLabel_2.setText(b2);//对应lable中显示选中的文本
java时区设置
最新推荐文章于 2024-09-19 10:51:26 发布