首页上一页 1 下一页尾页 1 条记录 1/1页
《java从入门到精通》光盘5.14实例,运行出错
发表在Java图书答疑
2016-08-11
是否精华
是
否
版块置顶:
是
否
在eclipse上编写的此程序,在运行时控制台出现:
Exception in thread "main" java.util.IllegalFormatConversionException: H != zuoye.Date
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302)
at java.util.Formatter$FormatSpecifier.printDateTime(Formatter.java:2835)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2740)
at java.util.Formatter.format(Formatter.java:2520)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2940)
at zuoye.Date.main(Date.java:8)
字样,请问是什么原因?
public class Date {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Date date=new Date();
String hour=String.format("%tH",date);
String minute=String.format("%tM",date);
String second=String.format("%tS",date);
System.out.println("现在时间是:"+hour+"时"+minute+"分"+second+"秒");
}
}
Exception in thread "main" java.util.IllegalFormatConversionException: H != zuoye.Date
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302)
at java.util.Formatter$FormatSpecifier.printDateTime(Formatter.java:2835)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2740)
at java.util.Formatter.format(Formatter.java:2520)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2940)
at zuoye.Date.main(Date.java:8)
字样,请问是什么原因?
public class Date {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Date date=new Date();
String hour=String.format("%tH",date);
String minute=String.format("%tM",date);
String second=String.format("%tS",date);
System.out.println("现在时间是:"+hour+"时"+minute+"分"+second+"秒");
}
}