• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Time-Date Conversion??

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
Thanks,
Thejaswini.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the help Michael.

Thejaswini.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic