/** * @ibm-not-published */ public static void recycleCalendar( TGregorianCalendar cal, boolean resetTZ ) { if(resetTZ) { cal.setTimeZone(TimeZone.getDefault()); } synchronized(gregorianCalendars) { if( gcCount<gregorianCalendars.length ) { gregorianCalendars[gcCount++] = cal; } } } }
/** * @ibm-not-published */ public static void recycleCalendar( TGregorianCalendar cal, boolean resetTZ ) { if(resetTZ) { cal.setTimeZone(TimeZone.getDefault()); } synchronized(gregorianCalendars) { if( gcCount<gregorianCalendars.length ) { gregorianCalendars[gcCount++] = cal; } } } }
DateTime.TGregorianCalendar cal = DateTime.getCalendar(); try { cal.setTimeZone(tz); cal.set(year, month-1, day, hour, minute, second); return cal.getTime();
TGregorianCalendar cal = getCalendar(); try { cal.setTimeZone(tz); cal.set(year, month-1, day, hour, minute, second); cal.set(GregorianCalendar.MILLISECOND,0);
TGregorianCalendar cal = getCalendar(); try { cal.setTimeZone(tz); cal.set(year, month-1, day, hour, minute, second); cal.set(GregorianCalendar.MILLISECOND,0);
DateTime.TGregorianCalendar cal = DateTime.getCalendar(); try { cal.setTimeZone(tz); cal.set(year, month-1, day, hour, minute, second); return cal.getTime();
calSource.setTimeZone(source); calSource.setTime(date); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis());
calSource.setTimeZone(source); calSource.setTime(date); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis());
calSource.setTimeZone(source); calSource.setTime(date); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis());
calSource.setTimeZone(source); calSource.setTime(date); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis());
public static java.sql.Timestamp timeZoneTimestampConversion(java.sql.Timestamp date, TimeZone source, TimeZone target) { if( !source.equals(target) ) { // creation of a calendar for the date in the SOURCE tz DateTime.TGregorianCalendar calSource=DateTime.getCalendar(); // creation of a calendar for the same 'absolute time' in TARGET tz DateTime.TGregorianCalendar calTarget=DateTime.getCalendar(); try { calSource.setTimeZone(source); calSource.setTime(date); // offset to convert : source -> GMT int zoneOffsetSource=-calSource.get(Calendar.ZONE_OFFSET); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis()); // offset to convert : GMT -> XSP server tz int zoneOffsetTarget=calTarget.get(Calendar.ZONE_OFFSET); int dstOffsetTarget=calTarget.get(Calendar.DST_OFFSET); long totalOffset=((long)zoneOffsetSource)+dstOffsetSource+zoneOffsetTarget+dstOffsetTarget; // obtain a new date in xsp server tz date=new java.sql.Timestamp(date.getTime()+totalOffset); } finally { DateTime.recycleCalendar(calSource); DateTime.recycleCalendar(calTarget); } } return date; }
public static Date timeZoneConversion(Date date, TimeZone source, TimeZone target) { if( !source.equals(target) ) { // creation of a calendar for the date in the SOURCE tz DateTime.TGregorianCalendar calSource=DateTime.getCalendar(); // creation of a calendar for the same 'absolute time' in TARGET tz DateTime.TGregorianCalendar calTarget=DateTime.getCalendar(); try { calSource.setTimeZone(source); calSource.setTime(date); // offset to convert : source -> GMT int zoneOffsetSource=-calSource.get(Calendar.ZONE_OFFSET); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis()); // offset to convert : GMT -> XSP server tz int zoneOffsetTarget=calTarget.get(Calendar.ZONE_OFFSET); int dstOffsetTarget=calTarget.get(Calendar.DST_OFFSET); long totalOffset=((long)zoneOffsetSource)+dstOffsetSource+zoneOffsetTarget+dstOffsetTarget; // obtain a new date in xsp server tz date=new Date(date.getTime()+totalOffset); } finally { DateTime.recycleCalendar(calSource); DateTime.recycleCalendar(calTarget); } } return date; }
public static java.sql.Timestamp timeZoneTimestampConversion(java.sql.Timestamp date, TimeZone source, TimeZone target) { if( !source.equals(target) ) { // creation of a calendar for the date in the SOURCE tz DateTime.TGregorianCalendar calSource=DateTime.getCalendar(); // creation of a calendar for the same 'absolute time' in TARGET tz DateTime.TGregorianCalendar calTarget=DateTime.getCalendar(); try { calSource.setTimeZone(source); calSource.setTime(date); // offset to convert : source -> GMT int zoneOffsetSource=-calSource.get(Calendar.ZONE_OFFSET); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis()); // offset to convert : GMT -> XSP server tz int zoneOffsetTarget=calTarget.get(Calendar.ZONE_OFFSET); int dstOffsetTarget=calTarget.get(Calendar.DST_OFFSET); long totalOffset=((long)zoneOffsetSource)+dstOffsetSource+zoneOffsetTarget+dstOffsetTarget; // obtain a new date in xsp server tz date=new java.sql.Timestamp(date.getTime()+totalOffset); } finally { DateTime.recycleCalendar(calSource); DateTime.recycleCalendar(calTarget); } } return date; }
public static Date timeZoneConversion(Date date, TimeZone source, TimeZone target) { if( !source.equals(target) ) { // creation of a calendar for the date in the SOURCE tz DateTime.TGregorianCalendar calSource=DateTime.getCalendar(); // creation of a calendar for the same 'absolute time' in TARGET tz DateTime.TGregorianCalendar calTarget=DateTime.getCalendar(); try { calSource.setTimeZone(source); calSource.setTime(date); // offset to convert : source -> GMT int zoneOffsetSource=-calSource.get(Calendar.ZONE_OFFSET); int dstOffsetSource=-calSource.get(Calendar.DST_OFFSET); calTarget.setTimeZone(target); calTarget.setMillis(calSource.getMillis()); // offset to convert : GMT -> XSP server tz int zoneOffsetTarget=calTarget.get(Calendar.ZONE_OFFSET); int dstOffsetTarget=calTarget.get(Calendar.DST_OFFSET); long totalOffset=((long)zoneOffsetSource)+dstOffsetSource+zoneOffsetTarget+dstOffsetTarget; // obtain a new date in xsp server tz date=new Date(date.getTime()+totalOffset); } finally { DateTime.recycleCalendar(calSource); DateTime.recycleCalendar(calTarget); } } return date; }