首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

关于字符串转时间

2012-03-30 
求助关于字符串转时间得到的时间是“Thu Jun 06 1985 00:00:00 GMT+0800 (中国标准时间)” 这样的字符串怎么

求助关于字符串转时间
得到的时间是“Thu Jun 06 1985 00:00:00 GMT+0800 (中国标准时间)” 这样的字符串

  怎么改成yyyy-MM-dd的格式啊?

[解决办法]
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");

format.format(字符串);
[解决办法]
如果是字符串,你就要自己写一个程序。

拆分这个字符串,然后构造一个Calendar.

然后用SimpleDateFormat

明白吗?
[解决办法]

探讨

SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");

format.format(字符串);

[解决办法]
“Thu Jun 06 1985 00:00:00 GMT+0800 (中国标准时间)”已经是字符串了,很难了,除非自己解析。
正确的做法应该是拿到时间对象,再用SimpleDateFormat
[解决办法]
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");

format.format("这是是日期");
出来的就是你想要的格式了。

[解决办法]
new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss' GMT'Z' (中国标准时间)'",Locale.ENGLISH);
[解决办法]
探讨

new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss' GMT'Z' (中国标准时间)'",Locale.ENGLISH);

[解决办法]
csdn整天大姨妈 真2
[解决办法]
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test {

/**
* @param args
*/
public static void main(String[] args) {
SimpleDateFormat formart = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date("Thu Jun 06 1985 00:00:00 GMT+0800");
System.out.println(formart.format(date));
}

}

結果:1985-06-06
[解决办法]
SimpleDateFormat formart = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date("Thu Jun 06 1985 00:00:00 GMT+0800");
System.out.println(formart.format(date));

热点排行