Sebastien Cesbron | 19 Dec 11:07 2006
Picon

Probleme with 1900-1-1

Hi,

I want to convert java.sql.Date to org.joda.time.DateTime but I have a problem with the date 1900-1-1. Here is my code

java.sql.Date date = new java.sql.Date(0,0,1);
org.joda.time.DateTime dateTime = new org.joda.time.DateTime(date.getTime());
System.out.println(dateTime);

the output is : "1899-12-31T23:09:21.000+00:09:21"

but with

java.sql.Date date = new java.sql.Date(0,0,2);
org.joda.time.DateTime dateTime = new org.joda.time.DateTime(date.getTime());
System.out.println(dateTime);

the output is "1900-01-02T00:00:00.000+00:09:21".

And with

java.sql.Date date = new java.sql.Date(99,0,1);
org.joda.time.DateTime dateTime = new org.joda.time.DateTime(date.getTime());
System.out.println(dateTime);

the output is "1999-01-01T00:00:00.000+01:00"


I don't understand this "+00:09:21" timezone at the beginning of the century. If somebody can explains me.

I am using joda 1.2.1. Is there any workaround to solve this 1900-1-1 problem ?

Seb

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Joda-interest mailing list
Joda-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest
Stephen Colebourne | 20 Dec 23:05 2006

Re: Probleme with 1900-1-1

The +09:21 is a time zone effect, referring to the latitude/longitude of 
the zone's location. This is used for dates before time zones were 
introduced.

To convert without this effect, use
LocalDate.fromDateFields(date)
YearMonthDay.fromDateFields(date)

Stephen

Sebastien Cesbron wrote:
> Hi,
> 
> I want to convert java.sql.Date to org.joda.time.DateTime but I have a 
> problem with the date 1900-1-1. Here is my code
> 
> java.sql.Date date = new java.sql.Date(0,0,1);
> org.joda.time.DateTime dateTime = new 
> org.joda.time.DateTime(date.getTime());
> System.out.println(dateTime);
> 
> the output is : "1899-12-31T23:09:21.000+00:09:21"
> 
> but with
> 
> java.sql.Date date = new java.sql.Date(0,0,2);
> org.joda.time.DateTime dateTime = new 
> org.joda.time.DateTime(date.getTime());
> System.out.println(dateTime);
> 
> the output is "1900-01-02T00:00:00.000+00:09:21".
> 
> And with
> 
> java.sql.Date date = new java.sql.Date(99,0,1);
> org.joda.time.DateTime dateTime = new 
> org.joda.time.DateTime(date.getTime());
> System.out.println(dateTime);
> 
> the output is "1999-01-01T00:00:00.000+01:00"
> 
> 
> I don't understand this "+00:09:21" timezone at the beginning of the 
> century. If somebody can explains me.
> 
> I am using joda 1.2.1. Is there any workaround to solve this 1900-1-1 
> problem ?
> 
> Seb
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Joda-interest mailing list
> Joda-interest <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/joda-interest

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane