> I wonder ...
>
> =========================================================
> GMT : 16/Nov/2000:19:21:40 +0900
> Required Time format : 2000-11-17, 04.21.40 (<== hour + 9)
> =========================================================
>
> I used "DateFormat", "SimpleDateFormat", "Timezone"..etc.
> But I can't find a proper java class.
>
> Please explain how to change it.
Hi,
You were looking along the right lines; you need a combination
of SimpleDateFormat and SimpleTimeZone to format the date for
non-local timezones. Something like this should do it...
import java.text.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
// initialise a calendar with the time using GMT timezone
// November is month 10 not 11 as months go from 0 to 11 in
Java
GregorianCalendar cal = new GregorianCalendar(2000, 10, 16,
19, 21, 40);
Date date = cal.getTime();
// set up a date formatter for the required output format
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd,
hh.mm.ss");
// set up a timezone for GMT+0900
SimpleTimeZone tz = new SimpleTimeZone(9 * 60 * 60 * 1000,
"GMT+0900");
df.setTimeZone(tz);
// print the date using the formatter
System.out.println(df.format(date));
}
}
Cheers,
Dave.
--
David Long <davidl@w...>
Wrox Press - Programmer to Programmer(tm)
http://p2p.wrox.com/
---
You are currently subscribed to pro_java as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_java-$subst('Recip.MemberIDChar')@p2p.wrox.com