You probably need to update your time zone information in Joda-Time:
http://joda-time.sourceforge.net/tz_update.html
Stephen
2008/10/27 Fabio Kenji Kume <[EMAIL PROTECTED]>:
> Hello,
>
> I've noticed that there is a strange behavior for the timezone
> "America/Sao_Paulo" concerning setting dates to midnight;
> I've run the following code and I've gotten different results using
> java.util.Calendar and Joda:
>
> public static void main(String[] args) {
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.YEAR,2008);
> cal.setLenient(false);
> cal.set(Calendar.MONTH,Calendar.OCTOBER);
> cal.set(Calendar.DAY_OF_MONTH,17);
>
> cal.set(Calendar.HOUR_OF_DAY,cal.getActualMinimum(Calendar.HOUR_OF_DAY));
> cal.set(Calendar.MINUTE,cal.getActualMinimum(Calendar.MINUTE));
> cal.set(Calendar.SECOND,cal.getActualMinimum(Calendar.SECOND));
>
> cal.set(Calendar.MILLISECOND,cal.getActualMinimum(Calendar.MILLISECOND));
>
> System.out.println(System.getProperty("user.timezone") );
> System.out.println(cal.getTime());
> System.out.println(cal.getTimeInMillis());
> System.out.println(new DateMidnight(2008,10,17).getMillis());
> System.out.println(new
> DateTime(cal.getTimeInMillis()).withMillisOfDay(0).getMillis());
> }
>
> output:
> America/Sao_Paulo
> Fri Oct 17 00:00:00 BRT 2008
> 1224212400000
> 1224208800000
> 1224208800000
>
>
> I've also run the following code:
> public static void main(String[] args) {
> int dayOfMonth = 10;
> int limit = 25;
>
> System.out.println(System.getProperty("user.timezone"));
> System.out.println(System.getProperty("java.version"));
> System.out.println(System.getProperty("java.home"));
>
> for(; dayOfMonth< limit; dayOfMonth++){
> System.out.println( "October " + dayOfMonth+ " 2008:");
> try{
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.YEAR,2008);
> cal.set(Calendar.MONTH,Calendar.OCTOBER);
> cal.set(Calendar.DAY_OF_MONTH,dayOfMonth);
>
> cal.set(Calendar.HOUR_OF_DAY,cal.getActualMinimum(Calendar.HOUR_OF_DAY));
>
> cal.set(Calendar.MINUTE,cal.getActualMinimum(Calendar.MINUTE));
>
> cal.set(Calendar.SECOND,cal.getActualMinimum(Calendar.SECOND));
>
> cal.set(Calendar.MILLISECOND,cal.getActualMinimum(Calendar.MILLISECOND));
> System.out.println( "Calendar : " +cal.getTimeInMillis()+"
> / " + cal.getTime()+" / "+ cal.getTimeZone().getID());
>
> }catch(Exception e){
> System.out.println( "Calendar : " + e.getMessage()+" on
> dayOfMonth +" + dayOfMonth);
> continue;
> }
>
> try{
> DateMidnight time = new DateMidnight(new
> DateTime().withYear(2008).withMonthOfYear(10).withDayOfMonth(dayOfMonth));
> System.out.println( "Joda : " + time.getMillis()+" / "
> + time.toDate()+" / " + time.getZone().getID());
> }catch(Exception e){
> System.out.println( "Joda : " + e.getMessage()+" on
> dayOfMonth $dayOfMonth");
> continue;
> }
> }
> }
>
>
> output:
>
> 1.5.0_14
> C:\Program Files\Java\jdk1.5.0_14\jre
> October 10 2008:
> Calendar : 1223607600000 / Fri Oct 10 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1223607600000 / Fri Oct 10 00:00:00 BRT 2008 / America/Sao_Paulo
> October 11 2008:
> Calendar : 1223694000000 / Sat Oct 11 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1223694000000 / Sat Oct 11 00:00:00 BRT 2008 / America/Sao_Paulo
> October 12 2008:
> Calendar : 1223780400000 / Sun Oct 12 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1223780400000 / Sun Oct 12 00:00:00 BRT 2008 / America/Sao_Paulo
> October 13 2008:
> Calendar : 1223866800000 / Mon Oct 13 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1223863200000 / Sun Oct 12 23:00:00 BRT 2008 / America/Sao_Paulo
> October 14 2008:
> Calendar : 1223953200000 / Tue Oct 14 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1223949600000 / Mon Oct 13 23:00:00 BRT 2008 / America/Sao_Paulo
> October 15 2008:
> Calendar : 1224039600000 / Wed Oct 15 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1224036000000 / Tue Oct 14 23:00:00 BRT 2008 / America/Sao_Paulo
> October 16 2008:
> Calendar : 1224126000000 / Thu Oct 16 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1224122400000 / Wed Oct 15 23:00:00 BRT 2008 / America/Sao_Paulo
> October 17 2008:
> Calendar : 1224212400000 / Fri Oct 17 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1224208800000 / Thu Oct 16 23:00:00 BRT 2008 / America/Sao_Paulo
> October 18 2008:
> Calendar : 1224298800000 / Sat Oct 18 00:00:00 BRT 2008 / America/Sao_Paulo
> Joda : 1224295200000 / Fri Oct 17 23:00:00 BRT 2008 / America/Sao_Paulo
> October 19 2008:
> Calendar : 1224385200000 / Sun Oct 19 01:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224381600000 / Sat Oct 18 23:00:00 BRT 2008 / America/Sao_Paulo
> October 20 2008:
> Calendar : 1224468000000 / Mon Oct 20 00:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224468000000 / Mon Oct 20 00:00:00 BRST 2008 /
> America/Sao_Paulo
> October 21 2008:
> Calendar : 1224554400000 / Tue Oct 21 00:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224554400000 / Tue Oct 21 00:00:00 BRST 2008 /
> America/Sao_Paulo
> October 22 2008:
> Calendar : 1224640800000 / Wed Oct 22 00:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224640800000 / Wed Oct 22 00:00:00 BRST 2008 /
> America/Sao_Paulo
> October 23 2008:
> Calendar : 1224727200000 / Thu Oct 23 00:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224727200000 / Thu Oct 23 00:00:00 BRST 2008 /
> America/Sao_Paulo
> October 24 2008:
> Calendar : 1224813600000 / Fri Oct 24 00:00:00 BRST 2008 /
> America/Sao_Paulo
> Joda : 1224813600000 / Fri Oct 24 00:00:00 BRST 2008 /
> America/Sao_Paulo
>
> It seems that the divergence between dates start at October 13th and end at
> October 19th. I'm not sure if there's any relation to this matter, but
> October 12th was one of the supposed days that Brazil would start using DST
> and it was postponed to October 19th, its official date. That said, it seems
> thta Calendar's output is the right one.
>
> Any ideas as to why this is happening? I'm using joda 1.5.2 and I've updated
> the JVM with the most recent tzupdater patch, 1.3.9.
>
> Thanks,
> Fabio
>
> ________________________________
> Receba GRÁTIS as mensagens do Messenger no seu celular quando você estiver
> offline. Conheça o MSN Mobile! Crie já o seu!
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest