将String类装换成Date类我知道怎么解决,就是利用SimpleDateFormat类
但是若要转换成GregorianCalendar类,
其实很简单:
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = timeFormat.parse(str);
date = new Date(date.getTime());
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
return calendar;
代码中只要多加calendar.setTime(date)这句就搞定了。
但是若要转换成GregorianCalendar类,
其实很简单:
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = timeFormat.parse(str);
date = new Date(date.getTime());
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
return calendar;
代码中只要多加calendar.setTime(date)这句就搞定了。
解决方案 »
- 《算法导论的Java实现》 11 基本数据结构
- java如何连接MSDE
- 调查: 大家平时看书(技术)是怎么看的?
- 急:::::如何配置TOMCAT5.0+struts-1.3.8
- ■一初级J2SE程序求稿,拟做PDA的备忘录,谢谢大家.■
- Button与线程的问题
- 请问该怎样制作java应用程序的安装程序?200分求助?
- 怎样把文件从服务器下载到本地,问题比较菜,但是分不少
- 请问哪位朋友有jbuilder 8 enterprise 的serial number或者activation file?
- 请教读取相对路径问题,小问题却搞了半天。。急!
- 关于基本类型的重载请教各位
- JAVA国际化的一个小例子,系统为啥不使用默认资源类????
鼓励一下你的自我探索行为,哈哈