There are some application we need to set GMT instated to sent current time. Following code will help to get accurate Blackberry GMT hours.
Hope this code will help full.
Calendar rightnow = Calendar.getInstance(TimeZone.getDefault()); int offsetDST = TimeZone.getDefault().getOffset(1, rightnow.get(Calendar.YEAR), rightnow.get(Calendar.MONTH), rightnow.get(Calendar.DAY_OF_MONTH), rightnow.get(Calendar.DAY_OF_WEEK), rightnow.get(Calendar.MILLISECOND)); System.out.println("Offset (Daylight Savings): "+ offsetDST); System.out.println(("Offset (Without Daylight Savings): "+ TimeZone.getDefault().getRawOffset())); System.out.println("GNT Time: "+(float)offsetDST/3600000); this.timezone = ""+(float)offsetDST/3600000; System.out.println("GMT: "+timezone);
Hope this code will help full.
No comments:
Post a Comment