sql.append.String.format(" and action_datetime <= %d", endTime);
一个日期型的字段用%什么表示啊?试了好多都不对用%d的话提示
ava.util.IllegalFormatConversionException: d != java.util.Date
java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
打出来的字段是
action_datetime <= Tue Oct 25 00:00:00 GMT+08:00 2011求解
一个日期型的字段用%什么表示啊?试了好多都不对用%d的话提示
ava.util.IllegalFormatConversionException: d != java.util.Date
java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
打出来的字段是
action_datetime <= Tue Oct 25 00:00:00 GMT+08:00 2011求解
解决方案 »
- 多参数查询如何实现????
- WindowBuilder装上后怎么用
- 关于java验证用户是否登录的问题
- hibernate多表查询求相应的HQL语句
- Apache Tomcat 7.0正式发布 支持Servlet 3.0
- 不知道错在哪了
- 关于tomcat的启动问题
- JMS可以实现双向的异步通讯吗?高分
- mm求教,高手赐招!急。。。急。。。(jwsdp1.3 上生成的web service例子在weblogic7.0上部署的问题)
- 用wsad开发一个管理系统,应该如何进行布局和架构设计?
- 求大家给我一个使用HttpURLConnection传递xml消息体访问网站和解析访问者发送过来的xml消息体的例子
- 求struts2制作的代码
public class TestNumFormat {
public static void main(String[] args) {
DecimalFormat df1 = new DecimalFormat("###.00");
System.out.println(df1.format(234234.234634));
System.out.println(df1.format(34.234634));
DecimalFormat df2 = new DecimalFormat("0.00E0000");
System.out.println(df2.format(23423.34234234));
DecimalFormat df3 = (DecimalFormat)NumberFormat.getInstance(Locale.CHINESE);
df3.applyPattern("####.000");
System.out.println(df3.format(23423.34234234));
df3.applyPattern("00.0000%");
System.out.println(df3.format(0.5552445));
NumberFormat nf1 = NumberFormat.getInstance();
System.out.println(nf1.format(13423423.234234));
NumberFormat nf2 = NumberFormat.getPercentInstance();
System.out.println(nf2.format(0.55));
}
}
输出结果:
234234.23
34.23
2.34E0004
23423.342
55.5244%
13,423,423.234
55%
System.out.print(String.format(" and action_datetime <= %1$tF %1$tT", new Date()));
Date date = new Date();
String str = String.format("%2$tY-%2$tm-%2$td: %1$,d", count, date);
System.out.println(str);
日期用的是t(time),d代表十进制整形数字decimal
其中%1,代表第一个参数,在格式化输出的时候,如果格式化输出的顺序与参数不一致或者某个参数要多次输出,会用到。%2$tY 代表第二个参数,按照日期格式,输出其四位年(Y),后面月日类似
%1$,d 代表第二个参数,按照十进制整形格式输出,并且,三位一撇
Java 5.0 Tiger程序高手秘笈
http://www.oreilly.com.cn/index.php?func=book&isbn=7-5641-0120-2