But how do I know if its AM or PM? I think the hours are 0-23. In which case it should give me 14:49:25.
Use c.get(Calendar.AM_PM)==Calendar.AM to find out
Also, will this algorithm take the leap seconds into account?
It will not. I'd suggest you to make sure if those seconds are important for your project, before you dig any deeper with them.
I am concerned about the performance issues in the real time project.
You do not need to compute the offset every time you do conversion, it's not going to change Compute it once, and keep the offset as a static member in your class. All arithmetic on constants will be done at compile time. Other than that the conversion takes just 2 additions and 2 multiplications. [ August 10, 2004: Message edited by: Dmitry Melnik ]
So far this is working fine (not bothering about the leap seconds).
I think I have the necessity to format date and time now.
I can use SimpleDateFormat the date and time but I guess I will be getting a string in in each case. I need to insert these values in the data base with the 'date' and 'time' fields (or just one field 'timestamp' which has both date,time and time zone ).
The requirement is I should be able to query the latest record using time and date. So I am wondering how to do that.
The simpleDateFormat gives me the wrong month [2004-49-11] while it is supposed to give me [2004-8-11]. Could you please tell me what the problem is? Also I will be glad if there is a way to display time in 0-23 hr instead of am or pm. Thank you!
The simpleDateFormat gives me the wrong month [2004-49-11] while it is supposed to give me [2004-8-11]. Could you please tell me what the problem is? Also I will be glad if there is a way to display time in 0-23 hr instead of am or pm.
Can any one tell me if the algorithm I wrote(included in the previous msg) takes care of the daylight savings ?
The algorithm that you wrote converts GPS week/time to "Java-UTC time" (which is true UTC + leap seconds). All the conversion to any local time is being done by relevant JDK classes/methods (Date, Calendar, etc). Read class documentation for details on handling timezones and daylight savings.