The com.javaranch.common package has a JDate (That's Julian Date, I believe...) class that tracks a date as an integer -- very useful for date arithmetic. Although there don't seem to be methods for converting to/from java.util.Date objects...feel free to try to implement those.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Use GregorianCalendar. E.G. use its add() method to implement your dateadd functionality. Use Calendar's getTimeInMillis() to convert two dates, do the subtraction for diff and then use setTimeInMills() to get your diff date result. Hope this helps.
Originally posted by Vasudevan Gopalan: Can any one have useful functions like dateadd,datediff,trim ?
I must confess I've always found the whole Java Date area totally confusing. They have tried to build a multilingual data system, but the result is a mess.
I know this doesn't help you ... but I just feel cross about it. So be warned - you WILL get confused! On the other hand, maybe you could read up about it, come up with a brilliantly simple replacement, and make all our lives better. Go for it!
Hi Vasu! You come from the fantastic world of Visual Basic, eh? Me too. I also have a difficult time with the date manipulation (and haven't quite gotten around to figuring it out), but I might be able to help with Trim(). I do not have exact syntax, but I think you should be able to use stringVariable.replace(' ',''). This should remove all spaces in the string. If you want the same functionality as Trim() you could do a substring like this: stringVariable = stringVariable.substring(1,stringVariable.length - 1). So if stringVariable = " Hello " then it should say "Hello" after the substring has executed. Best of luck, Lisa M.