您的位置:首页 > 其它

把格式日期转换成毫秒

2012-09-08 18:15 344 查看
  /**
*  把"yyyy-MM-dd HH:mm:ss"格式日期转换成毫秒
*@param strDate
*@return 转换后毫秒的值
*@author hongj
*/
public long paseDateTomillise(String strDate){
String year = null;
String month = null;
String day = "";
String hms = "";
if(strDate.contains(" ") && !strDate.endsWith(" ")){
String[] s = strDate.split(" ");
hms = s[1];
}
String[] getYear = strDate.split("-");
year = getYear[0].substring(2, 4);
month = getYear[1];
if("1".equalsIgnoreCase(month) || "01".equalsIgnoreCase(month)){
month = "JAN";
}else if("2".equalsIgnoreCase(month) || "02".equalsIgnoreCase(month)){
month = "FEB";
}else if("3".equalsIgnoreCase(month) || "03".equalsIgnoreCase(month)){
month = "MAR";
}else if("4".equalsIgnoreCase(month) || "04".equalsIgnoreCase(month)){
month = "APR";
}else if("5".equalsIgnoreCase(month) || "05".equalsIgnoreCase(month)){
month = "MAY";
}else if("6".equalsIgnoreCase(month) || "06".equalsIgnoreCase(month)){
month = "JUN";
}else if("7".equalsIgnoreCase(month) || "07".equalsIgnoreCase(month)){
month = "JUL";
}else if("8".equalsIgnoreCase(month) || "08".equalsIgnoreCase(month)){
month = "AUG";
}else if("9".equalsIgnoreCase(month) || "09".equalsIgnoreCase(month)){
month = "SEPT";
}else if("10".equalsIgnoreCase(month)){
month = "OCT";
}else if("11".equalsIgnoreCase(month)){
month = "NOV";
}else if("12".equalsIgnoreCase(month)){
month = "DEC";
}
if(getYear[2].contains(" ")){
day = getYear[2].split(" ")[0];
}else{
day = getYear[2];
}
String datees = day+"-"+month+"-"+year+" "+hms;
Date datee = new Date(datees);
return datee.getTime();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: