import java.text.*;
import java.util.*;public class dformat {
public static void main (String a[]){
try {
/*
** we specify Locale.US since months are in english
** we want to parse a TimeStamp
*/
SimpleDateFormat sdf = new SimpleDateFormat
("dd-MMM-yyyy HH:mm:ss", Locale.US);
/*
** fix timezone in the SimpleDateFormat
** bug in JDK1.1
*/
sdf.setCalendar(Calendar.getInstance());
/*
** create a Date (no choice, parse returns a Date object)
*/
Date d = sdf.parse("24-Feb-1998 17:39:35");
System.out.println(d.toString());
/*
** create a GregorianCalendar from a Date object
*/
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(d);
System.out.println(gc.getTime().toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
import java.util.*;public class dformat {
public static void main (String a[]){
try {
/*
** we specify Locale.US since months are in english
** we want to parse a TimeStamp
*/
SimpleDateFormat sdf = new SimpleDateFormat
("dd-MMM-yyyy HH:mm:ss", Locale.US);
/*
** fix timezone in the SimpleDateFormat
** bug in JDK1.1
*/
sdf.setCalendar(Calendar.getInstance());
/*
** create a Date (no choice, parse returns a Date object)
*/
Date d = sdf.parse("24-Feb-1998 17:39:35");
System.out.println(d.toString());
/*
** create a GregorianCalendar from a Date object
*/
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(d);
System.out.println(gc.getTime().toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
解决方案 »
- 菜鸟求解2个习题
- java的boolean类型的默认值不是false吗?
- 使用UE(UltraEdit )操作一个文本,现在要将一个大写字母变成小写字母
- swing 中TableCellEditor 可编辑事件
- 100分求中文(繁体简体标点符号)在Unicode下的范围(要精确)在JDK1.4下,JDK1.4下
- 关于system.in一个奇怪的问题
- ibatis问题
- 怎么实现把JTextArea的内容读到io流中 我想用io流中的readline()方法
- 请问如何在java中导如入用3DMAX做成的.MAX模型???
- java中如何求得两个日期之间相差的天数?
- JAVA的JDialog或JFame如何设置只允许扩大,不允许缩小
- 上溯造型问题(高手请进,高分有奖)
String dateformat='YYYY-MM-DD HH24:MI:SS';
..to_date(date , dateformat)..;