aspose file tools*
The moose likes Beginning Java and the fly likes Date function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date function" Watch "Date function" New topic
Author

Date function

Vasudevan Gopalan
Ranch Hand

Joined: Aug 29, 2003
Posts: 67
Can any one have useful functions like dateadd,datediff,trim ?

Regards
Vasu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

I really have no idea what you are asking about, but I'm assuming it is regarding date manipulation. As such, moving to Java in General (Beginner).
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Balaji Balasubramaniam
Greenhorn

Joined: Oct 09, 2003
Posts: 3
Look at java.util.Date class. It may be useful to you.


--Balaji<br />SCJP1.4,SCWCD,SCBCD
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

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.
Peter Kleczka
Greenhorn

Joined: Feb 09, 2003
Posts: 18
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 ?

Regards
Vasu
zhu a ming
Greenhorn

Joined: Oct 05, 2003
Posts: 9
java.util.date


=======================<br />s=(LinkNode *)malloc(sizeof(ListNode));<br /> s->date=ch;<br /> s->next=head;<br /> head=s;<br /> ch=getchar();
Simon Pearce
Greenhorn

Joined: Jul 22, 2003
Posts: 4
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!
Jerome Lumpkin
Greenhorn

Joined: Aug 28, 2001
Posts: 10
Just don't forget about that annoying feature in GregorianCalendar, wherin the months are relative to 0 and not 1.
Jerome A. Lumpkin
Colin Pace
Greenhorn

Joined: Sep 25, 2003
Posts: 9
you can read an excellent article on using java dates:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-dates.html

Colin Pace
Lisa D'Aniello
Ranch Hand

Joined: Sep 25, 2003
Posts: 42
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.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I feel that java Date classes were not designed properly. In fact there was a request for new Java Date classes bu Sun rejected it.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Here is link to java date discussion
http://www.javalobby.com/thread.jsp?forum=61&thread=4758
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Thanks for the good link Pradeep.
zhuam,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Date function