Re: java.sql.Timestamp and toString output
- From: "Richard Reynolds" <richiereynolds@xxxxxxxxxxxx>
- Date: Sun, 06 May 2007 17:40:17 GMT
"Richard Reynolds" <richiereynolds@xxxxxxxxxxxx> wrote in message
news:2Xm%h.6879$H4.3173@xxxxxxxxxxxxxxxxxxxxxxx
just tried it, first thing to note is they're not nanos, the way the
"Lew" <lew@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:N8ednfLah9PRV6DbnZ2dnUVZ_qHinZ2d@xxxxxxxxxxxxxx
Greg B wrote:
On May 5, 10:48 pm, Lew <l...@xxxxxxxxxxxxxxxxxxxx> wrote:
Greg B wrote:
accordingGreat. You verified the Javadocs. Looks like they were right.
tohttp://java.sun.com/j2se/1.5.0/docs/api/java/sql/Timestamp.html#toString(),
Returns:
a String object in yyyy-mm-dd hh:mm:ss.fffffffff format
however, when I do
import java.sql.Timestamp;
..
Timestamp ts = new Timestamp(1000);
System.out.println("Timestamp.toString(): " + ts.toString());
I get
Timestamp.toString(): 1970-01-01 10:00:01.0 (notice the formatting of
the nanos).
if I were to do ts.setNanos(1), then my output screen would contain
the 01.00000001
--
Lew
How's 10:00:01.0 in hh:mm:ss.fffffffff format?
As I understand that format string, it indicates that up to nine (?)
fractional digits will show, but it is usual in formatted output to show
fewer fractional digits when that is sufficient to represent the value.
I see no problem.
--
Lew
so does it do: 10:00:01.1 or 10:00:01.00000001 like the OP claimed?
original poster constructed it they're millis, but for 2 timestamps created
using 1000 and 1001 millis:
Timestamp.toString(): 1970-01-01 01:00:01.0
Timestamp.toString(): 1970-01-01 01:00:01.001
so, yes, inconsistency abounds!
if I do setNanos(0) and setNanos(1) on the same timestamp:
Timestamp.toString(): 1970-01-01 01:00:01.0
Timestamp.toString(): 1970-01-01 01:00:01.000000001
so again, inconsistent, bug I'd say.
.
- Follow-Ups:
- Re: java.sql.Timestamp and toString output
- From: Greg B
- Re: java.sql.Timestamp and toString output
- References:
- java.sql.Timestamp and toString output
- From: Greg B
- Re: java.sql.Timestamp and toString output
- From: Lew
- Re: java.sql.Timestamp and toString output
- From: Greg B
- Re: java.sql.Timestamp and toString output
- From: Lew
- Re: java.sql.Timestamp and toString output
- From: Richard Reynolds
- java.sql.Timestamp and toString output
- Prev by Date: Re: Stupid dialog closing question
- Next by Date: Re: Why does this program fall into endless loop?
- Previous by thread: Re: java.sql.Timestamp and toString output
- Next by thread: Re: java.sql.Timestamp and toString output
- Index(es):