Discussions

Web tier: servlets, JSP, Web frameworks: Problem with DATE...help me..

  1. Problem with DATE...help me.. (3 messages)

    Hy,

       Here i have a problem with date.
       i am storing a date as sting in oracle9i the format is

       19-JAN-2003 like.

       while it is retrieving it gets changed.
       in to 2003-01-19 00:00:00: like


        how can i get the original one from database.

     by

    Threaded Messages (3)

  2. Using java.text.SimpleDateFormat[ Go to top ]

    That's easy to format date .
  3. Problem with DATE...help me..[ Go to top ]

    Hi,

    Simply use a DateFormat object

    Here is a sample of code adapted from Sun tutorial ...
     //your code here
     Date date = resultSet.getDate(index);
     String dateOut;
     DateFormat dateFormatter;

      dateFormatter =
          DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale);
          // check Sun tutorial for others formaters
          today = new Date();
          dateOut = dateFormatter.format(today);

          System.out.println(dateOut + " " + currentLocale.toString());

    Hope it helps ....
  4. SQL[ Go to top ]

    Try to change your retrieval code from the sql to something like

    select to_char(yourDate, 'DD-MON-YYYY') genericName from yourDB

    That should return a string in the form of the way you're storing it.

    hth
    Chuck