Give this a shot.
Date bgnDate = rs.getDate("BeginDate");
String beginDate = "";
if(bgnDate != null)
{
beginDate = formatter.format(bgnDate);
}
Regards
Dan
Akebulan Enterprises LLC
http://www.akebulan.com
----- Original Message -----
From: <email@hidden>
To: <email@hidden>
Sent: Wednesday, March 08, 2006 3:03 PM
Subject: Java-dev Digest, Vol 3, Issue 105
> Send Java-dev mailing list submissions to
> email@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.apple.com/mailman/listinfo/java-dev
> or, via email, send a message with subject or body 'help' to
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Java-dev digest..."
>
>
> Today's Topics:
>
> 1. Testing to see if it is a Date (Elton Hughes)
> 2. Re: Serial Port I/O (Nick Howes)
> 3. Re: Testing to see if it is a Date (J. Simon Tack)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 8 Mar 2006 11:35:52 -0800
> From: Elton Hughes <email@hidden>
> Subject: Testing to see if it is a Date
> To: Java Mac <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hello All,
>
>
> I have created a JDBC class that prints out a list of clients in our
> database. A part of the code looks like this:
>
> Date bgnDate = rs.getDate("BeginDate");
> String beginDate = formatter.format(bgnDate);
>
> Date estDate = rs.getDate("EstimatedEndDate");
> String estEndDate = formatter.format(estDate);
>
> Date eDate = rs.getDate("EndDate");
> String endDate = formatter.format(eDate);
>
> Unfortunately, it is valid to not have an EstimatedEndDate or
> EndDate. They can be null.
>
> How do I test to to see if something is there before trying to format
> a NULL, which will trigger a exception.
>
> Thanks,
>
> Elton
>
> =========================================================
> NOVA 505 W. Olive Ave. Suite 550
> Elton Hughes (IT) Sunnyvale CA 94086
> Phone: 408-730-7235 Fax: 408-730-7643
> ---------------------------------------------------------
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 8 Mar 2006 12:47:13 -0700
> From: Nick Howes <email@hidden>
> Subject: Re: Serial Port I/O
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> On Mar 8, 2006, at 12:33 PM, Michael Rice wrote:
>
> > I'm trying to port an application that uses the javax.comm package.
> > Is there a good implementation for this on OS X? I'm using a Keyspan
> > USB->Serial adapter and Java 1.4.2_09. I've tried the RXTXcomm
> > package, but I always get a PortInUseException when I call
> > CommPortIdentifier.open(). The Keyspan diags say the port is OK and
> > available.
>
> FWIW, I use "SerialPort" <http://www.serialio.com/products/serialport/
> serialport.htm>. It ain't free, but it works well. I use their
> native API, but I understand they support the javax.comm API as well.
>
> - Nick
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 08 Mar 2006 14:50:13 -0500
> From: "J. Simon Tack" <email@hidden>
> Subject: Re: Testing to see if it is a Date
> To: Java Mac <email@hidden>
> Message-ID: <C0349FA5.3BE%email@hidden>
> Content-Type: text/plain; charset="US-ASCII"
>
> Hi Elton,
>
> Take a look at ResultSet.wasNull()
>
> >From javadoc:
>
> boolean wasNull()
> throws SQLException
>
> Reports whether the last column read had a value of SQL NULL. Note
that
> you must first call one of the getter methods on a column to try to read
its
> value and then call the method wasNull to see if the value read was SQL
> NULL.
>
> Returns:
> true if the last column value read was SQL NULL and false
otherwise
> Throws:
> SQLException - if a database access error occurs
>
>
>
> Just check this after calling getDate().
>
> -Simon
>
>
> On 3/8/06 2:35 PM, "Elton Hughes" <email@hidden> wrote:
>
> > Hello All,
> >
> >
> > I have created a JDBC class that prints out a list of clients in our
> > database. A part of the code looks like this:
> >
> > Date bgnDate = rs.getDate("BeginDate");
> > String beginDate = formatter.format(bgnDate);
> >
> > Date estDate = rs.getDate("EstimatedEndDate");
> > String estEndDate = formatter.format(estDate);
> >
> > Date eDate = rs.getDate("EndDate");
> > String endDate = formatter.format(eDate);
> >
> > Unfortunately, it is valid to not have an EstimatedEndDate or
> > EndDate. They can be null.
> >
> > How do I test to to see if something is there before trying to format
> > a NULL, which will trigger a exception.
> >
> > Thanks,
> >
> > Elton
> >
> > =========================================================
> > NOVA 505 W. Olive Ave. Suite 550
> > Elton Hughes (IT) Sunnyvale CA 94086
> > Phone: 408-730-7235 Fax: 408-730-7643
> > ---------------------------------------------------------
> >
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Java-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> >
http://lists.apple.com/mailman/options/java-dev/email@hidden
> >
> > This email sent to email@hidden
> >
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Java-dev mailing list
> email@hidden
> http://lists.apple.com/mailman/listinfo/java-dev
>
> End of Java-dev Digest, Vol 3, Issue 105
> ****************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden