Log.d(TAG, Formatter.formatFileSize(this, 100)); //100 B Log.d(TAG, Formatter.formatFileSize(this, 1024*2)); //2.00 KB Log.d(TAG, Formatter.formatFileSize(this, 10000000)); //9.54 MB
int flagsDate = DateUtils.FORMAT_SHOW_DATE; int flagsTime = DateUtils.FORMAT_SHOW_TIME ; int flagsWeek = DateUtils.FORMAT_SHOW_WEEKDAY; int flags_time = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR; String dateStr = (String)DateUtils.formatDateTime(this, System.currentTimeMillis(), flagsDate); //7月8日 String timeStr = (String)DateUtils.formatDateTime(this, System.currentTimeMillis(), flagsTime); //下午1:33 String weekStr = (String)DateUtils.formatDateTime(this, System.currentTimeMillis(), flagsWeek); //星期二 String amPmStr = DateUtils.getAMPMString(Calendar.getInstance().get(Calendar.AM_PM)); //下午 String datetime = DateFormat.format("yyyy:MM:dd kk:mm:ss", System.currentTimeMillis()).toString(); //2014:07:08 13:33:23 String time = (String)DateUtils.formatDateTime(this, System.currentTimeMillis(), flags_time); //13:33 boolean isToday = DateUtils.isToday(System.currentTimeMillis()); //true
原文地址:http://blog.csdn.net/heqiangflytosky/article/details/37569925