java - Date does not match in different programming language with System date -


hi having problem date. date returned java , php not matches system date.

here system settings date , time

date = 05-13-2013 10:58  time zone info = (utc+05:00) islamabad, karachi 

java

dateformat df = new simpledateformat("mm-dd-yyyy hh:mm a"); system.out.println(df.format(new date()));  timezone zone = timezone.getdefault(); system.out.println(zone.getdisplayname()); system.out.println(zone.getid()); 

result:

05-13-2013 12:58

central standard time

america/mexico_city

php

echo ini_get('date.timezone')." ======= ".date_default_timezone_get()."<hr>"; echo date("m-d-y h:i:s a", mktime()); 

result

utc ============== utc

05-13-2013 06:02:21

i tried every thing unable fix issue, people have suggested set time zone in php.ini fix issue, want programming languge should pick system timezone , date & time.

i need solution java possible java code pick date , time(timezone) of system, instead of configuration settings. (as want code should transparent, should run on server anywhere in world time zone, must of system)

if above not possible timezone settings can configured (please note running standalone application , application on jboss, schedule tasks).

edit:

what have tried successful result running java class print date.

standalone

javac mycurrentdate.java java -duser.timezone="gmt+5" mycurrentdate 

print correctly

jboss have added -duser.timezone param in run.bat

set java_opts=%java_opts% -xms512m -xmx1124m -xx:permsize=256m -duser.timezone="gmt+5"

but again looking global solution (every instance of java code should return correct date of system date)

few people have recommended timezone updater tool. belive updates list of timezone jdk , jre, , there no such option change current timezone. http://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html

which operating system using? have seen similar issues locales on windows, local system account had different locale domain users.

thereby, processes running services had different locale processes started domain user.

my solution log on server console mstsc /console , change timezone server.

edit: have i'm java developer primary work not server maintenance, , issue happened while back. experience on windows 2003 server, recall, had been installed company's management department.

when logged in user through remote desktop, change timezone correct one, applications server run service did still use old (wrong) timezone after restart.

i had log in through console mentioned in original post (probably local administrator) before got correct timezone set application server.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -