DateFormat 的一个疑问 大家都知道,DateFormat 是一个抽象类,可是为什么这个抽象类里竟然有创建实例的方法:public static final DateFormat getInstance()这个是什么原因呢?不知道这个方法的源码里是怎么实现的啊?它到底是创建的谁的实例呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 他创建的是SimpleDateFormat的实例 ... public final static DateFormat getInstance() { return getDateTimeInstance(SHORT, SHORT);}public final static DateFormat getDateTimeInstance(int dateStyle,int timeStyle) { return get(timeStyle, dateStyle, 3, Locale.getDefault());}private static DateFormat get(int timeStyle, int dateStyle,int flags, Locale loc) { if ((flags & 1) != 0) { if (timeStyle < 0 || timeStyle > 3) { throw new IllegalArgumentException("Illegal time style " + timeStyle); } } else { timeStyle = -1; } if ((flags & 2) != 0) { if (dateStyle < 0 || dateStyle > 3) { throw new IllegalArgumentException("Illegal date style " + dateStyle); } } else { dateStyle = -1; } try { return new SimpleDateFormat(timeStyle, dateStyle, loc); } catch (MissingResourceException e) { return new SimpleDateFormat("M/d/yy h:mm a"); } } 上面的代码少个常量public static final int SHORT = 3; 我的Eclipse打开DateFormat.class文件后,就能看到源码~不知道是不是装了什么插件,我用的是别人给的Eclipse window.top iframe使用例子 为什么-Integer.MIN_VALUE还是等与Integer.MIN_VALUE呢??? 各位有没有做过JAVA读写CAN方面的? 关于java1.5问题 Java报错 如何将两个字节数组合并成一个字节数组 刚来java 版.请大家多多照顾. 请问谁用过JSDT2。0 请教一个entity bean的问题 java 加密函数,高分求解 如何是JLabel不随文字的长度而改变大小 如何用下拉列表来改变一个文本框的值?
return getDateTimeInstance(SHORT, SHORT);
}public final static DateFormat getDateTimeInstance(int dateStyle,int timeStyle) {
return get(timeStyle, dateStyle, 3, Locale.getDefault());
}private static DateFormat get(int timeStyle, int dateStyle,int flags, Locale loc) {
if ((flags & 1) != 0) {
if (timeStyle < 0 || timeStyle > 3) {
throw new IllegalArgumentException("Illegal time style " + timeStyle);
}
} else {
timeStyle = -1;
}
if ((flags & 2) != 0) {
if (dateStyle < 0 || dateStyle > 3) {
throw new IllegalArgumentException("Illegal date style " + dateStyle);
}
} else {
dateStyle = -1;
}
try {
return new SimpleDateFormat(timeStyle, dateStyle, loc); } catch (MissingResourceException e) {
return new SimpleDateFormat("M/d/yy h:mm a");
}
}
public static final int SHORT = 3;
不知道是不是装了什么插件,我用的是别人给的Eclipse