Time problem on unix with j2sdk1.4.2_15 - shows 1hr behind the actual time
I have a java program which shows the date/time one hour behind the actual time.
This is the output :
linux> date- showing correct data/time when I use unix date command
Fri Jul 6 16:06:45 EDT 2007
When I run Java prgm to display current date , this is the output which shows one hour behind the actual time
linux> java142/j2sdk1.4.2_15/bin/java TimeTest
todays date ::07/06/2007 15:06PM
This is the java program:
import java.text.SimpleDateFormat;
import java.util.*;
class TimeTest
{
public static void main(String[] args) throws Exception
{
String m_uiDateFormat = "MM/dd/yyyy HH:mma";
SimpleDateFormat sdfUIDate = new SimpleDateFormat(m_uiDateFormat);
String strToday = sdfUIDate.format(new java.util.Date());
System.out.println("todays date ::"+strToday);
}
}
Please let me know what is the problem?
The same program is displaying correct time on another linux box. This is related to environment, but not getting any clue how to fix it.
Please help...
[1103 byte] By [
Pavalua] at [2007-11-27 9:55:58]

> I have a java program which shows the date/time one
> hour behind the actual time.
>
> This is the output :
>
> linux> date- showing correct data/time when I use
> unix date command
> Fri Jul 6 16:06:45 EDT 2007
>
> When I run Java prgm to display current date , this
> is the output which shows one hour behind the actual
> time
> linux> java142/j2sdk1.4.2_15/bin/java TimeTest
> todays date ::07/06/2007 15:06PM
>
> This is the java program:
> import java.text.SimpleDateFormat;
> import java.util.*;
>
> class TimeTest
> {
> public static void main(String[] args) throws
> Exception
>{
>String m_uiDateFormat = "MM/dd/yyyy HH:mma";
> SimpleDateFormat sdfUIDate = new
> SimpleDateFormat(m_uiDateFormat);
> String strToday = sdfUIDate.format(new
> ormat(new java.util.Date());
> System.out.println("todays date
> ::"+strToday);
> }
> }
>
> Please let me know what is the problem?
> The same program is displaying correct time on
> another linux box. This is related to environment,
> but not getting any clue how to fix it.
> Please help...
II'd bet its Daylight saving time.Compare the date to the DLS time start/end date
and if it is between add 1 hours to your date.Change the sytem date
to before/after daylght saving time to test this hypothesis.
(T)