public StringBuffer format(Date date,StringBuffer dateStrBuf,FieldPosition fieldPosition){
  int start=dateStrBuf.length();
  super.format(date,dateStrBuf,fieldPosition);
  int pos=0;
  for (pos=start + 25; dateStrBuf.charAt(pos) != 'X'; pos++)   ;
  calendar.clear();
  calendar.setTime(date);
  int offset=calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
  if (offset < 0) {
    dateStrBuf.setCharAt(pos++,'-');
    offset=(-offset);
  }
 else   dateStrBuf.setCharAt(pos++,'+');
  int rawOffsetInMins=offset / 60 / 1000;
  int offsetInHrs=rawOffsetInMins / 60;
  int offsetInMins=rawOffsetInMins % 60;
  dateStrBuf.setCharAt(pos++,Character.forDigit((offsetInHrs / 10),10));
  dateStrBuf.setCharAt(pos++,Character.forDigit((offsetInHrs % 10),10));
  dateStrBuf.setCharAt(pos++,Character.forDigit((offsetInMins / 10),10));
  dateStrBuf.setCharAt(pos++,Character.forDigit((offsetInMins % 10),10));
  return dateStrBuf;
}

public StringBuffer format ( Date date , StringBuffer dateStrBuf , FieldPosition fieldPosition ) { int start = dateStrBuf . length ( ) ; super . format ( date , dateStrBuf , fieldPosition ) ; int pos = 0 ; for ( pos = start + 25 ; dateStrBuf . charAt ( pos ) != 'X' ; pos ++ ) ; calendar . clear ( ) ; calendar . setTime ( date ) ; int offset = calendar . get ( Calendar . ZONE_OFFSET ) + calendar . get ( Calendar . DST_OFFSET ) ; if ( offset < 0 ) { dateStrBuf . setCharAt ( pos ++ , '-' ) ; offset = ( - offset ) ; } else dateStrBuf . setCharAt ( pos ++ , '+' ) ; int rawOffsetInMins = offset / 60 / 1000 ; int offsetInHrs = rawOffsetInMins / 60 ; int offsetInMins = rawOffsetInMins % 60 ; dateStrBuf . setCharAt ( pos ++ , Character . forDigit ( ( offsetInHrs / 10 ) , 10 ) ) ; dateStrBuf . setCharAt ( pos ++ , Character . forDigit ( ( offsetInHrs % 10 ) , 10 ) ) ; dateStrBuf . setCharAt ( pos ++ , Character . forDigit ( ( offsetInMins / 10 ) , 10 ) ) ; dateStrBuf . setCharAt ( pos ++ , Character . forDigit ( ( offsetInMins % 10 ) , 10 ) ) ; return dateStrBuf ; }
formats the given date in the format specified by draft - ietf - drums - msg - fmt - 08 in the current timezone .
