/**
* 获取年
* @return
*/
public static int getYear(){
Calendar cd = Calendar.getInstance();
return cd.get(Calendar.YEAR);
}
/**
* 获取月
* @return
*/
public static int getMonth(){
Calendar cd = Calendar.getInstance();
return cd.get(Calendar.MONTH)+1;
}
/**
* 获取日
* @return
*/
public static int getDay(){
Calendar cd = Calendar.getInstance();
return cd.get(Calendar.DATE);
}
/**
* 获取时
* @return
*/
public static int getHour(){
Calendar cd = Calendar.getInstance();
return cd.get(Calendar.HOUR);
}
/**
* 获取分
* @return
*/
public static int getMinute(){
Calendar cd = Calendar.getInstance();
return cd.get(Calendar.MINUTE);
}
/**
* 获取当前时间的时间戳
* @return
*/
public static long getCurrentTimeMillis(){
return System.currentTimeMillis();
}
/**
* 获取当前时间
*/
public static String getCurrentTime(){
return getFormatedDateTime(System.currentTimeMillis());
}
/** * 将long转换为日期(yyyy-MM-dd HH:mm) * @param dateTime * @return 到分 */ @SuppressLint("SimpleDateFormat") public static String getFormatedDateTime(long dateTime) { String time=""; try { SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); time=sDateFormat.format(new Date(dateTime + 0)); }catch (Exception e){ } return time; }