Written a class of J2ME operational dates, only one method is to add an increment to the date, then calculate the date

xiaoxiao2021-03-06  40

When I did it, I found a strange problem, running a normal program on the Sony Ericsson T610 and T630, running the error through Bluetooth to T628, strange ~~~~ Who can explain it to me ~~~ Class of operation date The following: / * * Created on 2005-1-14 * * Todo to change the Template for this generated file go to * window - preferences - java - code style - code templates * / package com.booolee;

Import java.util. *;

/ ** * @Author libo * * Todo to change the template for this generated type comment Go to * window - preferences - java - code style - code templates * / public class bobo_date {/ ** * Increase / reduce dates Operation * @Param D Date * @Param Days Increment Day * @Return Date * / Public Date Add (D, Int Days) {Int Year, Month, Month2, Month_r, Day, Day2, Day_R, I; Boolean ryear; Int dayofmonths [] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; Calendar Cal; Cal = Calendar.GetInstance (); Cal.SetTime (D); Year = Cal.get (Cal.Year); Month = Cal.Get (Cal.Mont); day = ca.get (cal.day_of_month); day2 = day days; // Judgment is a leap year IF ((Year% 4 == 0 && year% 100! = 0) || Year% 400 == 0) {ryear = true;} else {ryear = false;} // If it is a leap year, in February is 29 days if it is 28 days IF ( {dayofmonths [1] = 29;} else {dayofmonths [1] = 28;} // span is a few months, request results month I = 0; While (TRUE) {IF ((Month i)> 11) {MONTH = 1; i = 0; year ;} day_r = day2; day2 = day2-dayofmonths [MONTH I]; if (day2 <0) {MONTH_R = Month i 1; Break;} else {i CAL. Set (Cal.Year, Year); Cal.Set (Cal.Month, Month); Cal.Set (CAL.DAY_OF_MONTH, DAY_R); Return Cal.getTime ();

}

转载请注明原文地址:https://www.9cbs.com/read-68792.html

New Post(0)