Results 1 to 5 of 5
- 05-22-2012, 11:49 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 16
- Rep Power
- 0
number of the days (-) days gone past
Hello Folks
On my form I want to display the number of day.. i.e.
Jan 1 is day 1
jan 2 is day 2
Feb 1 is day 32 and december 31 is day 365 or 366 depending on leap year or not
i have used all kind of techniques such as date1 - date2 etc...
but nothing seems to work for me cant get the logic right may be.. what i want is count and add the number of the months that has gone past plus the number days of the running month i. 22nd may 2012 is day number (31(jan)+29(feb)+31(mar)+30(apr)+22(currentdate)) = 145 and they will keep adding plus one every time a day go past... thanks
- 05-22-2012, 12:30 PM #2
Re: number of the days (-) days gone past
Read the API for java.util.Calendar
Or if this is homework and you have to reinvent the wheel, post your best efforts and indicate where exactly you still have a problem.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-22-2012, 12:32 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: number of the days (-) days gone past
So what code have you got so far, since you say you have "used all kind of techniques"?
Please do not ask for code as refusal often offends.
- 05-22-2012, 12:50 PM #4
Member
- Join Date
- Dec 2011
- Posts
- 16
- Rep Power
- 0
Re: number of the days (-) days gone past
its not a homework its real work which i am doin free for someone....
there are few more which doesnt make sence but i cant manage to get the logic right...Java Code://constructor public DateDifference() { Calendar cal1 = new GregorianCalendar(); Calendar cal2 = new GregorianCalendar(); cal1.getTime(); //System.out.println(cal1); cal2.set(2012, 01, 01); //System.out.println(cal2); //daysBetween(cal1.getTime(), cal2.getTime()); System.out.println("Days= "+ this.daysBetween(cal1.getTime(),cal2.getTime())); } public int daysBetween(java.util.Date date, java.util.Date date2){ return (int)( (date2.getTime() - date.getTime()) / (1000 * 60 * 60 * 24)); }
thanks
- 05-22-2012, 01:17 PM #5
Member
- Join Date
- Dec 2011
- Posts
- 16
- Rep Power
- 0
Similar Threads
-
Help, I have been working on this for days
By ajimda in forum New To JavaReplies: 2Last Post: 10-28-2011, 04:46 PM -
Best way to find number of days between 2 dates??
By alinaqvi90 in forum Advanced JavaReplies: 18Last Post: 11-22-2010, 08:49 AM -
Calendar days mixed up..
By tomblue84 in forum AWT / SwingReplies: 0Last Post: 03-17-2010, 05:08 PM -
No fo days between two dates
By Java Tip in forum Java TipReplies: 0Last Post: 01-28-2008, 09:06 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks