• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Date Format

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a frame which has a textbox , the values of which should be date and should update a date in a MS Access Database.
The date in the Access database is of Date/Time type with Short Date format.
How should I convert the string to date format which can be inserted in the database.

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're working with swings, try using JMaskedTextField instead of a JTextField. This should make things easier for you. I guess this code should convert your String to date format.
com.symantec.itools.javax.swing.JMaskedTextField mask =
new com.symantec.itools.javax.swing.JMaskedTextField();
String maskchar = new String("0000/00/00\\ 00:00:00:00");
mask.setDatatype(com.symantec.itools.javax.swing.JMaskedTextField.datetype);
mask.setText(Your String);
mask.setMask(maskchar);
Good Luck
Meghna
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That solution would only work if Milind was using Symantec/WebGain's Visual Cafe.

Or, if Milind was willing to use unlicensed class files.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another question regarding JMaskedTextField:
Does anyone know how to remove the underlined characters that are displayed in a JMaskedTextField? For instance, if I declare a JMaskedTextField with mask 000, i.e. three digit places, then at run-time when I focus on the JTextField "___" will appear. It's quite unsightly, seems like an odd default.
Thanks,
Hilda
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Milind,
there are some classes that help you check the input. see the section "How to use TextFields" in the swing tutorial (java.sun.com/docs etc).
the classes java.sql.Date/Time/Timestamp have each the static method valueOf(String). you can use this as a suppletive validation and conversion.
chantal
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Milind Deodhar:
I have a frame which has a textbox , the values of which should be date and should update a date in a MS Access Database.
The date in the Access database is of Date/Time type with Short Date format.
How should I convert the string to date format which can be inserted in the database.


u have something called Dateformat in calendar class .In that Parse method converts string to date. if u want to do vice versa, toString(calendar obj) is fine.
Thanujja
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic