@Test public void testGetUTCDateEpoh(){ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(2008); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(2008); utc.add(Calendar.MILLISECOND, -offset); Date expectedDate = utc.getTime(); Date actualDate = dateUtil.getUTCDate(2008); Assert.assertEquals(actualDate.getDate(),expectedDate.getDate()); Assert.assertEquals(actualDate.getMinutes(),expectedDate.getMinutes()); }
public static Date getUTCDate(){ try{ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); }catch(Exception ex){ return null; } }
DateUtil { public static Date getUTCDate(){ try{ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); }catch(Exception ex){ return null; } } }
DateUtil { public static Date getUTCDate(){ try{ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); }catch(Exception ex){ return null; } }  }
DateUtil { public static Date getUTCDate(){ try{ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); }catch(Exception ex){ return null; } }  Date getDateFromNow(int days); Date getDateFromNow(int days, int hours, int minutes); static String dateToString(Date date, String dateFromat); Date getDateFromGivenDate(Date date, int days, int hours,int minutes, int second); Date addTimeOffset(Date date, int mins); static Date getUTCDate(); static Date getUTCDate(long epoh); static Date getLocalDateForUTCDate(Date date); static Date stringToDate(String dateString, String dateFromat); }
DateUtil { public static Date getUTCDate(){ try{ Calendar local=Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); }catch(Exception ex){ return null; } }  Date getDateFromNow(int days); Date getDateFromNow(int days, int hours, int minutes); static String dateToString(Date date, String dateFromat); Date getDateFromGivenDate(Date date, int days, int hours,int minutes, int second); Date addTimeOffset(Date date, int mins); static Date getUTCDate(); static Date getUTCDate(long epoh); static Date getLocalDateForUTCDate(Date date); static Date stringToDate(String dateString, String dateFromat);  }