This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Time-Date Conversion?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Time-Date Conversion??" Watch "Time-Date Conversion??" New topic

Time-Date Conversion??

thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
Hi everyone,
My requirement is to accept user input(say from a textfield) which contains the time offset(with respect to GMT) and add/subtract it to the local date to generate a new date.The question is:

1.If am using a textfield to accept the input,then i can get the data with getText() mthd in JTextField.But the arg for the add() mthd in calender takes integer values to be added. How to bring about the conversion from String<->int?

2.How do I accept user input if i dont use a textfield?

can anyone please suggest how to go about this?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
here's a general routine, but note the format is yyyy/MM/dd and a date
like 05/1/1 will pass, even though the format might not be acceptable
elsewhere in your program - if so, you may have to include a length() test.

it is always easier to use a DatePicker - search this site, google etc
thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
Thanks for all the help Michael.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Time-Date Conversion??
jQuery in Action, 3rd edition