0

How to ignore timezone in dates? I mean I seted some jsf input with 8:54 with format HH:mm, and in setter I am getting 9:54, i Think that is because of time zone GMT+1. How to convert this date to ignore time zone? How to convert it when i dont know from which time zone I am using it.

code, setter of time picker input:

public void setDateTest(Date hmm){
    if (hmm!=null){
        int a = hmm.getHours();
        int b = hmm.getMinutes();

        Calendar cal = Calendar.getInstance();
        cal.get(Calendar.ZONE_OFFSET);
        cal.setTime(hmm);

        int a2 = cal.get(Calendar.HOUR);
        int c2 = cal.get(Calendar.HOUR_OF_DAY);
        int b2 = cal.get(Calendar.MINUTE);
    }
}
user2771738
  • 913
  • 11
  • 31

1 Answers1

0

if you are using java.util.Calendar (probably you are), Hour index is in range between 0-11

http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#HOUR

so if you are giving 8 for Calendar.HOUR, this is actually 9. This might be the cause. Just an opinion...

Sedat Kestepe
  • 95
  • 2
  • 9