//获取时间戳
long timecurrentTimeMillis = System.currentTimeMillis(); long timeGetTime =new Date().getTime(); long timeSeconds = System.currentTimeMillis(); long timeMillis = Calendar.getInstance().getTimeInMillis(); Log.d("test", " 当前时间戳1->:"+timecurrentTimeMillis); Log.d("test", " 当前时间戳2->:"+timeGetTime); Log.d("test", " 当前时间戳3->:"+timeSeconds); Log.d("test", " 当前时间戳4->:"+timeMillis);//转为yyyy年MM月dd日
SimpleDateFormat sdf =new SimpleDateFormat("yyyy年MM月dd日",Locale.getDefault()); String time1 = sdf.format(timecurrentTimeMillis); String time2 = sdf.format(timeGetTime); String time3 = sdf.format(timeSeconds); String time4 = sdf.format(timeMillis); Log.d("test", timecurrentTimeMillis +" 现在的时间1->:" + time1); Log.d("test", timeGetTime +" 现在的时间2-->:" + time2); Log.d("test", timeSeconds +" 现在的时间2-->:" + time3); Log.d("test", timeMillis +" 现在的时间2-->:" + time4);//转为yyyy年MM月dd日HH时mm分ss秒E
SimpleDateFormat sdfTwo =new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒E",Locale.getDefault()); String time11 = sdfTwo.format(timecurrentTimeMillis); String time22 = sdfTwo.format(timeGetTime); String time33 = sdfTwo.format(timeSeconds); String time44 = sdfTwo.format(timeMillis); Log.d("test", timecurrentTimeMillis +" 现在的时间11->:" + time11); Log.d("test", timeGetTime +" 现在的时间22-->:" + time22); Log.d("test", timeSeconds +" 现在的时间33-->:" + time33); Log.d("test", timeMillis +" 现在的时间44-->:" + time44);效果图: