Any web based application especially working with date and time (ie. ordering, scheduling, reports) requires to show in their local timezone rather than GMT time or deployed application server time.
Javascript Date object method Date.getTimezoneOffset() helps to find client timezone, This may not give direct timezones like Standard Time (IST), Eastern Standard Time (EST) etc.
Example can be found @ http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp
If our requirement to do the conversion process in business tier rather than client tier the below Java snippet helps.
Date date = new Date();
System.out.println("Now (Local) :" + date);
DateFormat outdfm = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a zzz");
outdfm.setTimeZone(TimeZone.getTimeZone("IST"));
System.out.println("IST Time :" + outdfm.format(date));
outdfm.setTimeZone(TimeZone.getTimeZone("EST"));
System.out.println("EST Time :" +outdfm.format(date));
Output :
Now (Local) :Wed Nov 17 10:27:27 IST 2010
IST Time :2010-11-17 10:27:27 AM IST
EST Time :2010-11-16 11:57:27 PM EST
An article http://www.odi.ch/prog/design/datetime.php might give more details of how these api works.
Subscribe to:
Post Comments (Atom)
Running Jobs as application user in Cloudera hadoop distribution
When an Hadoop cluster is not enabled with Kerberos authentication, Internally triggered jobs would be running as an 'yarn' user ra...
-
When an Hadoop cluster is not enabled with Kerberos authentication, Internally triggered jobs would be running as an 'yarn' user ra...
-
It is been de facto standard that writing a JUnit test and confirming ORM (Object Relational Mapping) layer perfect before validating servi...
-
Code coverage is one of the benchmark strategy for any commercial or opensource product. Cobertura is one of the best tool to generat...
No comments:
Post a Comment