係統粉 > 電腦問答 > 其他問答

已解決[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

boolean是布爾量其值隻有真和假2中其它太長懶得看了.... (1)
2017-01-11 12:32:25
讚 3
民樂嚎屁肽

民樂嚎屁肽

回答數:161  |  被采納數:133

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 );
}


簡短一下,其實就是這幾句有問題,該如何改呢??
2017-01-11 16:01:33
讚 16
非羽丶沫

非羽丶沫

回答數:132  |  被采納數:108

你能簡要的說明下 你這個程序主要是用來做什麼的嗎!?
2017-01-11 18:13:50
讚 13
霸氣de關關

霸氣de關關

回答數:126  |  被采納數:134

部分代碼沒有給全!

以及Integer.toString(int para)
API 傳遞的參數類型不對!

你的代碼太厲害了,我都看不出來,到底寫的是什麼!!
還麻煩你簡單的介紹下了!!
2017-01-11 14:34:07
讚 12
永愛少時和禹哲

永愛少時和禹哲

回答數:3  |  被采納數:84

就是給出一個具體的日期,比如公元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不對?那該怎樣改呢?
2017-01-11 14:04:43
讚 0
造搖書生

造搖書生

回答數:93  |  被采納數:81

我把你的第一個方法已經更改了其他的方法已經屏蔽掉了!
你自己把下麵的代碼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());}}複製代碼
2017-01-11 18:37:47
讚 9
鄉下的妹兒

鄉下的妹兒

回答數:192  |  被采納數:5


是這個結果了,謝謝幫忙(2)

另外想問一下大俠周末有時間不?考試很沒有信心啊(3)
2017-01-11 19:53:21
讚 19
偏激憤世不羈

偏激憤世不羈

回答數:71  |  被采納數:89

是這個結果就好了,
其他的方法你對照我寫的那個public String returnShortDate()自己修改下吧!!
周末不知道,有問題發帖子求助, 還有很多高手在的!!
我有時間就上來看看!!
2017-01-12 07:00:55
讚 7
江戶川卡洛

江戶川卡洛

回答數:86  |  被采納數:44

其實你的代碼 過於很複雜化了!
你自己去看看DateFormat 以及 SimpleDateFormat 定義幾個時間日期格式!
直接Format一下就OK了!
最多40行當代碼 給你搞得150多行去!!
而且可讀性相當的差!!
多看下API吧!
2017-01-12 09:55:17
讚 8
相關問答
最新其他問答
解決方法