Date获取年月日

/**
 * 日期格式化
 * @param date
 * @return
 */
private String dateStringFormat(Date date) {
    calendar.setTime(date);
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH) + 1;
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    return year + "年" + month + "月" + day + "日";
}

你可能感兴趣的:(Android开发)