項目中根據項目名稱選擇不同的AndroidManifest.xml文件
MY_PROJECT_NAME := $(subst full_,,$(TARGET_PRODUCT))
ifeq ($(strip $(MY_PROJECT_NAME)), xxxxxx) # xxxxxx 是自己項目名稱LOCAL_MANIFEST_FILE := xxx/AndroidManifest.xml #xxx 是自定義的文件夾名稱
endif
取得系統設定的日期顯示格式,然後顯示相應日期
private java.text.DateFormat getDateFormat() {
String format = Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT);
if (format == null || "".equals(format)) {
return java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
} else {
try {
return new java.text.SimpleDateFormat(format);
} catch (IllegalArgumentException e) {
// If we tried to use a bad format string, fall back to a default.
return java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
}
}
}
具體使用代碼:
private final Date currentTime = new Date();
currentTime.setTime(System.currentTimeMillis());
final String text = getDateFormat().format(mCurrentTime);
view.setText(text);
直接一句話:
android.text.format.DateFormat.getDateFormat(mContext).format(currentTime);