android得到系统时间如何判断是白天还是晚上

ContentResolver cv = getBaseContext().getContentResolver();
String strTimeFormat = android.provider.Settings.System.getString(cv, android.provider.Settings.System.TIME_12_24);
if(strTimeFormat!=null && strTimeFormat.equals("24"))
{
Log.i("Debug","24小时制");
}
else
{
String amPmValues;
Calendar c = Calendar.getInstance(); 
if(c.get(Calendar.AM_PM) == 0)
{
amPmValues = "AM";
}
else
{
amPmValues = "PM";
}
Log.i("Debug","12小时制现在是:" + amPmValues);
} 

posted on 2014-08-07 16:12  小尾巴猴子  阅读(447)  评论(0编辑  收藏  举报

导航