[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ajug-members]: Breaking up the SQL data



Here is the solution I came up with to convert the DATETIME format to
something more readable

            Timestamp p = rs.getTimestamp("DATE_SUB");
            SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yy
HH:mm");
            String r = formatter.format(p);
            out.println(r == null ? "(null)" : r);



On Wed, 2004-03-31 at 18:54, Chris Fowler wrote:
> On Wed, 2004-03-31 at 18:36, Angus Berry wrote:
> > Chris,
> > 
> > Is there some reason not to use java.sql.Date and all it's inherent
> > functionality?
> 
> Will it support the datetime format of MySQL?
> 
> mysql> describe CMS.ALARMS;
> +----------+---------------------------+------+-----+---------------------+----------------+
> | Field    | Type                      | Null | Key |
> Default             | Extra          |
> +----------+---------------------------+------+-----+---------------------+----------------+
> | ID       | int(10) unsigned zerofill |      | PRI |
> NULL                | auto_increment |
> | DATE_SUB | datetime                  |      |     | 1970-01-01
> 00:00:01 |                |
> | LOCATION | int(7)                    |      |     |
> 0                   |                |
> | CONSOLE  | varchar(250)              |      |    
> |                     |                |
> | ALARM    | varchar(250)              |      |    
> |                     |                |
> | STATUS   | int(10) unsigned          | YES  |     |
> NULL                |                |
> | LEVEL    | int(10) unsigned          | YES  |     |
> NULL                |                |
> | ASSIGNED | int(10) unsigned          | YES  |     |
> NULL                |                |
> +----------+---------------------------+------+-----+---------------------+----------------+
> 8 rows in set (0.00 sec)
> 
> 
> The DATETIME format is "YYYY-MM-DD HH:MM:SS";
> 
> 
> 
> 
> > 
> > On Wed, 2004-03-31 at 18:32, Chris Fowler wrote:
> > > I have the following class:
> > > 
> > > import java.util.*;
> > > 
> > > public class SQLDate {
> > >   private String DATE = "";
> > > 
> > >   public SQLDate(String v1) {
> > >     /**
> > >      * Format of v1:
> > >      * "YYYY-MM-DD HH:MM:SS"
> > >      */
> > >   }
> > > 
> > > }
> > > 
> > > /** vi: set ts=2 sw=2: */
> > > 
> > > String has a method that will allow it to create an array of strings
> > > based on a regex statement.  Is there a regex that can chop up the SQL
> > > date format into its pieces?
> > > 
> > > Thanks,
> > > Chris
> > > 
> > > 
> > > 
> > > ΒΆ