相等天赋异禀女主是谁的AUG 和ACP 到底谁更好

1578人阅读
java(16)
  在windows下使用DateFormat的parse方法,将字符中转化为Date类型时,一切正常。可安装到Linux下,就出现了ParseException异常。代码如下:
public Date toDateTime(String str){Date dt = new Date();
try{DateFdf = DateFormat.getDateTimeInstance();dt = df.parse(str); }catch(ParseException e){System.err.println(e);}}
我执行toDateTime(& 12:00:00&P),在windows下正常,Linux下出现ParseException异常。看来是Linux下的DateFormat对象不认 识& 12:00:00&P这种格式的字符串,所以转换不了(需进一步老确认)。
由于时间来不及,我赶紧换了另外一种方法。新的代码在Linux下运行正常。修改后的代码如下:
public Date toDate(String str){Date dt = new Date();String[] parts = str.split(&-&);
if(parts.length &= 3){int years = Integer.parseInt(parts[0]);int months = Integer.parseInt(parts[1]) - 1;int days = Integer.parseInt(parts[2]);int hours = 0;int minutes = 0;int seconds = 0;
GregorianCalendar gc = new GregorianCalendar(years,months,days,hours,minutes,seconds);
dt = gc.getTime();}}
我的日期字符串格式是&yyyy-MM-dd-HH-mm-ss&的,所以代码如上。要转化别的格式,截取字符中的时候会不一样。但,它的核心代码是 &GregorianCalendar gc = GregorianCalendar(years, months, days, hours, minutes, seconds);&。也就是用GregorianCalendar类来进行String到Date类型的转换。&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:216034次
积分:2515
积分:2515
排名:第13655名
原创:57篇
转载:17篇
评论:43条
(1)(1)(2)(3)(3)(2)(1)(3)(2)(1)(2)(3)(2)(6)(5)(1)(2)(1)(1)(2)(3)(2)(2)(3)(1)(1)(5)(4)(1)(1)(1)(6)所有回答(1)
貌似是你的web.xml有问题,我的web.xml文件定义为:
1 &?xml version= "1.0" encoding ="UTF-8" ?&
2 &beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
&bean id="helloWorldBean" class="cim.springNeed.HelloWorldBean"&
&property name="helloWorld"&
&value&Hello,Welcome To Spring World!&/value&
&/property&
14 &/beans&
这样就没啥问题,不过建议spring的配置文件定义为applicationContext.xml或spring.xml。
我将web.xml的&beans ...& &/beans&去掉后报你上面的错误。
园豆:1254
&&&您需要以后才能回答,未注册用户请先。

我要回帖

更多关于 天赋异禀北极星是谁 的文章

 

随机推荐