Since I cannot reproduce this problem on my computer. I guess this would relate about localization. Try this System.out.
Println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z",Locale. US). Format(new Date())) Hope this helps.
Since I cannot reproduce this problem on my computer. I guess this would relate about localization. Try this System.out.
Println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z",Locale. US). Format(new Date())); Hope this helps.
Localisation - yep, it looks like it. I have updated the question with some more information since you all mentioned it. – Andez Nov 22 at 15:27 glad that it helps :) – Surasin Tancharoen Nov 22 at 15:55 I think you really have to change "out timezone" to something correct like "America/Los_Angeles".
If you want to avoid daylight saving, the new SimpleTimeZone(0, "America/Los_Angeles") constructor already void that. Read its api doc. – Surasin Tancharoen Nov 22 at 16:28 Thanks Surasin.
Will check it out – Andez Nov 220 at 16:52.
System.out. Println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"). Format(new Date())); for me just returns 2011-11-22 13:42:16 GMT - so appears to work as you wish.
Looks like it might be a problem elsewhere, you shouldn't need to create your own formatter class though.
Yes. The finger of blame is now pointed back at us (not me). There is part of the system which calls a TimeZone.
SetDefault(new SimpleTimeZone(0, "our own name"). I have inherited this and I am not too sure what the way forward is. :-( Andez – Andez Nov 22 at 15:13.
I think that you are using the correct pattern for your requirements, however the JDK doesn't know the name of your timezone, so it switches over to using a GMT offset value instead. When I format a date using your pattern, I get "GMT" for the timezone part. What does TimeZone.getDefault().getDisplayName() give you?
For me, I get "Greenwich Mean Time".
Thanks sudocode... It helped identify the problem as there is some nasty code in there to set the default timezone to a custom timezone. – Andez Nov 22 at 15:20.
Not an elegant solution at all but it works for us. I had to create a custom implementation for DateFormat/SimpleDateFormat. This looks like something as follows: static { // this would be initialized like something as follows when the application starts // which causes the headaches of SimpleDateFormat not to work... SimpleTimeZone tz = new SimpleTimeZone(0, "Out Timezone"); TimeZone.
SetDefault(tz); } // therefore this class will workaround the issue, public class OurOwnCustomDateFormat extends SimpleDateFormat { /** The pattern to use as the format string. */ protected String pattern; public OurOwnCustomDateFormat(String pattern) { super(pattern); // store the pattern this. Pattern = pattern; } @Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) { // custom implementation to format the date and time based on our TimeZone toAppendTo.
Insert(pos.getBeginIndex(), "the date with our custom format calculated here"); return toAppendTo; }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.