> I wrote a date difference programs.  However, two programs give me
> different results? one day difference, why? Program 1, show me output as
> 365; Program 2, show me 364.
> 
> Both programs are identical except Program 2, embedded yy, mm, dd on the
> Calendar.set()  method.
> 
> 
> Program 1:
> import java.util.*;
> 
> public class Try {
>   public static void main(String[] arg) {
>   String ddd = "02/07/02";
>     int yy = 2000 + Integer.parseInt(ddd.substring(6,8));
>     int mm = Integer.parseInt(ddd.substring(0,2)) - 1;
>     int dd = Integer.parseInt(ddd.substring(3,5));
>     System.out.println(yy + " " + mm + " " + dd);
>   Calendar mat = Calendar.getInstance();
>     mat.set(yy, mm, dd);
>   Calendar now = Calendar.getInstance();
>   long days = (mat.getTime().getTime() - now.getTime().getTime()) /
> 86400000L;
>     System.out.println(days);
>   }
> }
> 
> Program 2:
> import java.util.*;
> 
> public class Try {
>   public static void main(String[] arg) {
>   String ddd = "02/07/02";
>   Calendar mat = Calendar.getInstance();
>     mat.set(2000 + Integer.parseInt(ddd.substring(6,8)),
>       Integer.parseInt(ddd.substring(0,2)) - 1,
>       Integer.parseInt(ddd.substring(3,5)));
>   Calendar now = Calendar.getInstance();
>   long days = (mat.getTime().getTime() - now.getTime().getTime()) /
> 86400000L;
>     System.out.println(days);
>   }
> }



------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers Inc.  Email transmission cannot be guaranteed to be 
secure or error-free.  Therefore, we do not represent that this information is 
complete or accurate and it should not be relied upon as such.  All information is 
subject to change without notice.


_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to