Correction:

I use the following:

      Date dtDateTime = new Date();    // Or whatever else it is to be

      GregorianCalendar gcUK = new GregorianCalendar(Locale.UK);
      TimeZone tzUK = TimeZone.getTimeZone("Europe/London");
      gcUK.setTimeZone(tzUK);
      gcUK.setTime(dtDateTime);

      DateFormat dfUK =
SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM,
       SimpleDateFormat.MEDIUM, Locale.UK);
      dfUK.setCalendar(gcUK);
      String sDate = dfUK.format(dtDateTime);

I cannot remember now why I repeat "dtDateTime", but it works for me.


On Aug 7, 8:28 am, Ian Marshall <[email protected]> wrote:
> The UTC time is the same everywhere at the same time.
>
> The trick is to format the date-time for a time zone.
>
> I use the following:
>
>       GregorianCalendar gcUK = new GregorianCalendar(Locale.UK);
>       TimeZone tzUK = TimeZone.getTimeZone("Europe/London");
>       gcUK.setTimeZone(tzUK);
>       gcUK.setTime(new Date());
>
>       DateFormat dfUK =
> SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM,
>        SimpleDateFormat.MEDIUM, Locale.UK);
>       dfUK.setCalendar(gcUK);
>       String sDate = dfUK.format(dtDateTime);
>
> Choose your own locale and time zone. Enjoy?
>
> On Aug 6, 5:38 pm, Stephen <[email protected]> wrote:
>
> > If I run :
>
> > Date now = new Date();
> > System.out.println(now);
>
> > from the main method of a plain java class I get :
> > Fri Aug 06 11:33:00 CDT 2010 as expected.
>
> > If I run that same code in a JSP app engine gives me :
> > Fri Aug 06 11:33:00 UTC 2010
>
> > Run that same JSP on tomcat and again I get :
> > Fri Aug 06 11:33:00 CDT 2010 as expected.
>
> > Even if I try to set the timezone manually I still get UTC from a JSP
> > hosted by app engine.
> > Any ideas what is going on here?
>
> > Thanks in advance.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to