public static String formatAsGeneralizedTime(final long date){
  final StringBuilder sb=new StringBuilder(19);
  final GregorianCalendar calendar=new GregorianCalendar(TIME_ZONE_UTC_OBJ);
  calendar.setLenient(false);
  calendar.setTimeInMillis(date);
  int n=calendar.get(Calendar.YEAR);
  if (n < 0) {
    final IllegalArgumentException e=new IllegalArgumentException("Year cannot be < 0:" + n);
    throw e;
  }
 else   if (n < 10) {
    sb.append("000");
  }
 else   if (n < 100) {
    sb.append("00");
  }
 else   if (n < 1000) {
    sb.append("0");
  }
  sb.append(n);
  n=calendar.get(Calendar.MONTH) + 1;
  if (n < 10) {
    sb.append("0");
  }
  sb.append(n);
  n=calendar.get(Calendar.DAY_OF_MONTH);
  if (n < 10) {
    sb.append("0");
  }
  sb.append(n);
  n=calendar.get(Calendar.HOUR_OF_DAY);
  if (n < 10) {
    sb.append("0");
  }
  sb.append(n);
  n=calendar.get(Calendar.MINUTE);
  if (n < 10) {
    sb.append("0");
  }
  sb.append(n);
  n=calendar.get(Calendar.SECOND);
  if (n < 10) {
    sb.append("0");
  }
  sb.append(n);
  sb.append('.');
  n=calendar.get(Calendar.MILLISECOND);
  if (n < 10) {
    sb.append("00");
  }
 else   if (n < 100) {
    sb.append("0");
  }
  sb.append(n);
  sb.append('Z');
  return sb.toString();
}

public static String formatAsGeneralizedTime ( final long date ) { final StringBuilder sb = new StringBuilder ( 19 ) ; final GregorianCalendar calendar = new GregorianCalendar ( TIME_ZONE_UTC_OBJ ) ; calendar . setLenient ( false ) ; calendar . setTimeInMillis ( date ) ; int n = calendar . get ( Calendar . YEAR ) ; if ( n < 0 ) { final IllegalArgumentException e = new IllegalArgumentException ( "Year cannot be < 0:" + n ) ; throw e ; } else if ( n < 10 ) { sb . append ( "000" ) ; } else if ( n < 100 ) { sb . append ( "00" ) ; } else if ( n < 1000 ) { sb . append ( "0" ) ; } sb . append ( n ) ; n = calendar . get ( Calendar . MONTH ) + 1 ; if ( n < 10 ) { sb . append ( "0" ) ; } sb . append ( n ) ; n = calendar . get ( Calendar . DAY_OF_MONTH ) ; if ( n < 10 ) { sb . append ( "0" ) ; } sb . append ( n ) ; n = calendar . get ( Calendar . HOUR_OF_DAY ) ; if ( n < 10 ) { sb . append ( "0" ) ; } sb . append ( n ) ; n = calendar . get ( Calendar . MINUTE ) ; if ( n < 10 ) { sb . append ( "0" ) ; } sb . append ( n ) ; n = calendar . get ( Calendar . SECOND ) ; if ( n < 10 ) { sb . append ( "0" ) ; } sb . append ( n ) ; sb . append ( '.' ) ; n = calendar . get ( Calendar . MILLISECOND ) ; if ( n < 10 ) { sb . append ( "00" ) ; } else if ( n < 100 ) { sb . append ( "0" ) ; } sb . append ( n ) ; sb . append ( 'Z' ) ; return sb . toString ( ) ; }
returns a string containing provided date formatted using the generalized time syntax .
