取得想要的时间格式:
方法一:
public static java.sql.Date strToDate(String str){
DateFormat df = new SimpleDateFormat("yyyy/mm/dd");
//SimpleDateFormat df1 = new SimpleDateFormat();
try {
Date d = (Date) df.parse(str);
return new java.sql.Date(d.getTime());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null ;
}
方法二:
public static Date changeStrToDate(String str){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
ParsePosition pos=new ParsePosition(1) ;
Date d = df.parse(str,pos);
return d;
}
public static int strToInt(String str){
int i = 0;
if(str!=null){
i = Integer.parseInt(str);
}
return i;
}
public static double strToDouble(String str){
double d = 0;
if(str!=null){
d = Double.parseDouble(str);
}
return d;
}