/**
* 日期转时间戳
*
* @param strDate
* @param simpleFormate
* @return
*/
public static long FormateStringDateToLong(String strDate, String simpleFormate) {
Date date = null;
long dateLong = 0;
SimpleDateFormat sdf = new SimpleDateFormat(simpleFormate);
try {
date = sdf.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
if (date != null) {
dateLong = date.getTime();
}
return dateLong;
}
-
-
-
/**
* 时间戳转日期 "yyyy-MM-dd HH:mm"
*
* @param strDate
* @return
*/
public static long FormateStringDateToLong1(String strDate) {
return FormateStringDateToLong(strDate, "yyyy-MM-dd HH:mm");
}
-
-
-
/**
* 时间戳转日期 "yyyy-MM-dd"
*
* @param strDate
* @return
*/
public static long FormateStringDateToLong2(String strDate) {
return FormateStringDateToLong(strDate, "yyyy-MM-dd");
}
-
-
-
/**
* 毫秒时间转 xx日xx时xx分
*/
public static String miSecondToDay(long mss) {
long days = mss / (1000 * 60 * 60 * 24);
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60);
// long seconds = (mss % (1000 * 60)) / 1000;
return days + "天" + hours + "小时" + minutes + "分";
}
-
-
-
/**
* 毫秒时间戳转日期
*/
public static String FormateTimeStempToString(long timeStemp, String simpleFormate) {
SimpleDateFormat sdf = new SimpleDateFormat(simpleFormate);
return sdf.format(timeStemp);
}
-
-
-
/**
* 毫秒时间戳转日期 yyyy-MM-dd HH:mm:ss
*/
public static String FormateTimeStempToString1(long timeStemp) {
return FormateTimeStempToString(timeStemp, "yyyy-MM-dd HH:mm:ss");
}
-
-
-
/**
* 日期之差
*
* @return
*/
public static long getDataExplan(String start, String end) {
Date date_start = null;
Date date_end = null;
long dateLong = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH:mm");
try {
date_start = sdf.parse(start);
date_end = sdf.parse(end);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (date_start != null && date_end != null) {
dateLong = date_end.getTime() - date_start.getTime();
}
return dateLong;
}