当前位置:系统粉 > 电脑问答 > 其他问答 > [100电元求解]想问一下Integer.toString为什么会有问题,该如何解决?谢谢大家先

[100电元求解]想问一下Integer.toString为什么会有问题,该如何解决?谢谢大家先

提问者:今生来世你的狐  |  浏览 次  |  提问时间:2017-01-11  |  回答数量:9

[100电元求解]想问一下Integer.toString为什么会有问题,该如何解决?谢谢大家先 class Date{ private finalintDAYSINAYEAR[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; private finalintDAYSINALEAPYEAR[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; privatefinal String FULLMONTH[] = { “ ”, “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }; private final String SHORTMONTH[] = { “ “, “Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sept”, “Oct”, “Nov”, “Dec”}; privatelong days ;

已有9条答案
懵or懂的小时分

懵or懂的小时分

回答数:38  |  被采纳数:66

2017-01-11 12:32:25
boolean是布尔量其值只有真和假2中其它太长懒得看了.... (1)
赞 3
民乐嚎屁肽

民乐嚎屁肽

回答数:161  |  被采纳数:133

2017-01-11 16:01:33
boolean returnShortDate() {

return Integer.toString ( determineGregorianMonth ( ) )+”/”+ Long.toString (determineGregorianDay ( ) )+”/”+ Long.toString (determineGregorianYear ( ) %100 );
}
boolean returnFullDate() {
int months = Integer.toString ( FULLMONTH[ ]);
return Integer.toString ( FULLMONTH[ ])+”, ”+ Long.toString (determineGregorianDay ( ) )+”, ”+ Long.toString (determineGregorianYear ( ) );
}

boolean returnEuroDate() {

return Integer.toString ( determineGregorianMonth ( ) )+”-”+ Long.toString (determineGregorianDay ( ) )+”-”+ Long.toString (determineGregorianYear ( ) %100 );
}

boolean returnSortableDate() {

return Long.toString ( determineGregorianYear ( ) ) + Integer.toString (determineGregorianMonth ( ) ) + Long.toString (determineGregorianDay ( ) );
}

boolean returnShortFullDate() {
int months = Integer.toString ( SHORTMONTH [ ]);
return Integer.toString ( SHORTMONTH [ ])+”. ”+ Long.toString (determineGregorianDay ( ) )+”, ”+ Long.toString (determineGregorianYear ( ) %100 );
}


简短一下,其实就是这几句有问题,该如何改呢??
赞 16
非羽丶沫

非羽丶沫

回答数:132  |  被采纳数:108

2017-01-11 18:13:50
你能简要的说明下 你这个程序主要是用来做什么的吗!?
赞 13
霸气de关关

霸气de关关

回答数:126  |  被采纳数:134

2017-01-11 14:34:07
部分代码没有给全!

以及Integer.toString(int para)
API 传递的参数类型不对!

你的代码太厉害了,我都看不出来,到底写的是什么!!
还麻烦你简单的介绍下了!!
赞 12
永爱少时和禹哲

永爱少时和禹哲

回答数:3  |  被采纳数:84

2017-01-11 14:04:43
就是给出一个具体的日期,比如公元2010年12月31日.这个日期与公元1年1月1日相隔总数多少天.多少年,多少月,跟天数.然后将2010年12月31日的格式写成5种表达形式:12/31/10(年份2010变10),December 31 ,2010,12-31-10, 2010 12 31跟Dec 31,10

API不对?那该怎样改呢?
赞 0
造摇书生

造摇书生

回答数:93  |  被采纳数:81

2017-01-11 18:37:47
我把你的第一个方法已经更改了其他的方法已经屏蔽掉了!
你自己把下面的代码copy下 来运行 看看第一个方法是不是你想要的结果!
class Date {private final int DAYSINAYEAR[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,30, 31 };private final int DAYSINALEAPYEAR[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30,31, 30, 31 };private final String FULLMONTH[] = { " ", "January", "February", "March","April", "May", "June", "July", "August", "September", "October","November", "December" };private final String SHORTMONTH[] = { " ", "Jan", "Feb", "Mar", "Apr","May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };private long days;/** * determineGregorianMonthDay * @return long */public long determineGregorianMonthDay() {long year = 1;int months = 1;long days = this.days;for (; days > (isALeapYear(year) ? 366 : 365); year++)days -= (isALeapYear(year) ? 366 : 365);for (; days > (isALeapYear(year) ? DAYSINALEAPYEAR[months - 1]: DAYSINAYEAR[months - 1]); months++)days -= (isALeapYear(year) ? DAYSINALEAPYEAR[months - 1]: DAYSINAYEAR[months - 1]);return days;}/** * determineGregorianMonthYear * @return long */public long determineGregorianMonthYear() {long year = 1;int months = 1;long days = this.days;for (; days > (isALeapYear(year) ? 366 : 365); year++)days -= (isALeapYear(year) ? 366 : 365);year++;for (; days > (isALeapYear(year) ? DAYSINALEAPYEAR[months - 1]: DAYSINAYEAR[months - 1]); months++)days -= (isALeapYear(year) ? DAYSINALEAPYEAR[months - 1]: DAYSINAYEAR[months - 1]);return months;}/** * determineGregorianYear * @return long */public long determineGregorianYear() {long year = 1;long days = this.days;for (; days > (isALeapYear(year) ? 366 : 365); year++)days -= (isALeapYear(year) ? 366 : 365);return year;}/** * determineJulianDate * @param year---long type * @param month---long type * @param day---long type */public void determineJulianDate(long year, long month, long day) {int yearCounter = 0;for (yearCounter = 1; yearCounter < year; yearCounter++)days += (isALeapYear(yearCounter)) ? 366 : 365;for (int monthCounter = 1; monthCounter < month; monthCounter++)days += (isALeapYear(yearCounter)) ? DAYSINALEAPYEAR[monthCounter - 1]: DAYSINAYEAR[monthCounter - 1];this.days += day;}/** * getDays * @return long */public long getDays() {return days;}/** * isALeapYear * @param year---long type * @return boolean */private boolean isALeapYear(long year) {return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) ? true: false;}// boolean returnShortDate() {////return Integer.toString ( determineGregorianMonth ( ) )+"/"+ Long.toString (determineGregorianDay ( ) )+"/"+ Long.toString (determineGregorianYear ( ) %100 );// }/** * returnShortDate * @return String */public String returnShortDate() {StringBuffer sb = new StringBuffer();sb.append(String.valueOf(determineGregorianMonthYear()));sb.append("/");sb.append(String.valueOf(determineGregorianMonthDay()));sb.append("/");sb.append(String.valueOf(determineGregorianYear() % 100));return sb.toString();}//boolean returnFullDate() {//int months = Integer.toString ( FULLMONTH[ ]);//return Integer.toString ( FULLMONTH[ ])+", "+ Long.toString (determineGregorianDay ( ) )+", "+ Long.toString (determineGregorianYear ( ) );// }////boolean returnEuroDate() {////return Integer.toString(determineGregorianMonth()) + "-"//+ Long.toString(determineGregorianDay()) + "-"//+ Long.toString(determineGregorianYear() % 100);//}////boolean returnSortableDate() {//return Long.toString(determineGregorianYear())//+ Integer.toString(determineGregorianMonth())//+ Long.toString(determineGregorianDay());//}////boolean returnShortFullDate() {//int months = Integer.toString ( SHORTMONTH [ ]);//return Integer.toString ( SHORTMONTH [ ])+". "+ Long.toString (determineGregorianDay ( ) )+", "+ Long.toString (determineGregorianYear ( ) %100 );// }}public class Driver {public static void main(String[] args) {Date aTestDate = new Date();aTestDate.determineJulianDate(10, 12, 31);System.out.println("Days is " + aTestDate.getDays());System.out.println("Days is " + aTestDate.determineGregorianMonthDay());System.out.println("months is "+ aTestDate.determineGregorianMonthYear());System.out.println("year is " + aTestDate.determineGregorianYear());System.out.println("shortDate is " + aTestDate.returnShortDate());//System.out.println("fullDate is "+aTestDate. returnFullDate());//System.out.println("euroDate is "+aTestDate. returnEuroDate());//System.out.println("sortableDate is "+aTestDate. returnSortableDate());//System.out.println("shortFullDate is "+aTestDate. returnShortFullDate());}}复制代码
赞 9
乡下的妹儿

乡下的妹儿

回答数:192  |  被采纳数:5

2017-01-11 19:53:21

是这个结果了,谢谢帮忙(2)

另外想问一下大侠周末有时间不?考试很没有信心啊(3)
赞 19
偏激愤世不羁

偏激愤世不羁

回答数:71  |  被采纳数:89

2017-01-12 07:00:55
是这个结果就好了,
其他的方法你对照我写的那个public String returnShortDate()自己修改下吧!!
周末不知道,有问题发帖子求助, 还有很多高手在的!!
我有时间就上来看看!!
赞 7
江户川卡洛

江户川卡洛

回答数:86  |  被采纳数:44

2017-01-12 09:55:17
其实你的代码 过于很复杂化了!
你自己去看看DateFormat 以及 SimpleDateFormat 定义几个时间日期格式!
直接Format一下就OK了!
最多40行当代码 给你搞得150多行去!!
而且可读性相当的差!!
多看下API吧!
赞 8
解决方法
版权信息

Copyright @ 2011 系统粉 版权声明 最新发布内容 网站导航