把20070903 09:00这段字符串转换成2007-09-02 08:00
最好写一个方法有个传入参数
麻烦大家啊,我数据结构确实不好啊
------解决方案--------------------或者时间转化
public static void main(String[] args) {
//SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss ");
try {
System.out.println(getStr( "20070903 09:00 "));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private static String getStr(String in)throws Exception{
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd HH:mm ");
Date d1 =sdf.parse(in);
sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm ");
return sdf.format(d1);
}