from java code i have to retrieve some data from a database, which is present in a different timezone.
Scenario :- My database is in different timezone. let's say current time for me is 11AM 16APR2012, where as time in database timezone is 9PM 15APR2012. I want to retrieve something from database on basis of time. So from my java code i am sending the date is 16APR2012.
select * from table_name where date = ?;
I want some logic, where i will be able to retrieve data from database according to the database time. for example if the database time is 15th then the placeholder will be populated with 15th, even if i am sending the date as 16th. and if i am sending the date is 16th and the database time is 16th, then the placeholder value will be populated with 16th.
In this case use of Calendar class will be more convenient than the Date class. You have to first find out the date from database and then you can get the TimeZone. Next you may specify your locale and can format the date using SimpleDateFormat class and set your timezone.