答案 0 :(得分:0)
如果我理解你的问题..试试这个......
Date d1 = new Date();
d1.setTime(time_in_milliseconds);
Calendar cal = Calendar.getInstance();
cal.setTime(d1);
然后你可以得到日,月,年..
int number_of_day = cal.get(Calendar.DAY_OF_MONTH)
答案 1 :(得分:0)
检查一下:
public Date getDateByFormat(String time, String format) {
if (time == null || "".equals(time)) return null;
try {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.ENGLISH);
return sdf.parse(time);
} catch (ParseException e) {
Log.d(Constants.TAG, "Could not parse date: " + time + " Due to: " + e.getMessage());
}
return null;
}
此格式是您的日期字符串格式。与"yyyy-MM-dd HH:mm:ss"