public void normalize(){
  if (isNormalized) {
    return;
  }
  if (iHours == 24 || hoursTimezone != null && (iHoursTimezone != 0 || iMinutesTimezone != 0)) {
    Calendar cal=new GregorianCalendar(iYear,iMonths - 1,iDays,iHours,iMinutes,iSeconds);
    if (isNegativeYear) {
      cal.set(Calendar.ERA,GregorianCalendar.BC);
    }
    if (isNegativeTimezone) {
      cal.add(Calendar.HOUR_OF_DAY,iHoursTimezone);
      cal.add(Calendar.MINUTE,iMinutesTimezone);
    }
 else {
      cal.add(Calendar.HOUR_OF_DAY,-iHoursTimezone);
      cal.add(Calendar.MINUTE,-iMinutesTimezone);
    }
    if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
      isNegativeYear=true;
    }
    iYear=cal.get(Calendar.YEAR);
    iMonths=cal.get(Calendar.MONTH) + 1;
    iDays=cal.get(Calendar.DAY_OF_MONTH);
    iHours=cal.get(Calendar.HOUR_OF_DAY);
    iMinutes=cal.get(Calendar.MINUTE);
    iSeconds=cal.get(Calendar.SECOND);
    year=int2string(iYear,4);
    months=int2string(iMonths,2);
    days=int2string(iDays,2);
    hours=int2string(iHours,2);
    minutes=int2string(iMinutes,2);
    seconds=int2string(iSeconds,2);
    if (hoursTimezone != null) {
      iHoursTimezone=iMinutesTimezone=0;
      hoursTimezone=minutesTimezone="00";
      isNegativeTimezone=false;
    }
  }
  if (fractionalSeconds != null) {
    int zeroCount=0;
    for (int i=fractionalSeconds.length() - 1; i >= 0; i--) {
      if (fractionalSeconds.charAt(i) == '0') {
        zeroCount++;
      }
 else {
        break;
      }
    }
    if (zeroCount == fractionalSeconds.length()) {
      fractionalSeconds=null;
    }
 else     if (zeroCount > 0) {
      fractionalSeconds=fractionalSeconds.substring(0,fractionalSeconds.length() - zeroCount);
    }
  }
  isNormalized=true;
}

public void normalize ( ) { if ( isNormalized ) { return ; } if ( iHours == 24 || hoursTimezone != null && ( iHoursTimezone != 0 || iMinutesTimezone != 0 ) ) { Calendar cal = new GregorianCalendar ( iYear , iMonths - 1 , iDays , iHours , iMinutes , iSeconds ) ; if ( isNegativeYear ) { cal . set ( Calendar . ERA , GregorianCalendar . BC ) ; } if ( isNegativeTimezone ) { cal . add ( Calendar . HOUR_OF_DAY , iHoursTimezone ) ; cal . add ( Calendar . MINUTE , iMinutesTimezone ) ; } else { cal . add ( Calendar . HOUR_OF_DAY , - iHoursTimezone ) ; cal . add ( Calendar . MINUTE , - iMinutesTimezone ) ; } if ( cal . get ( Calendar . ERA ) == GregorianCalendar . BC ) { isNegativeYear = true ; } iYear = cal . get ( Calendar . YEAR ) ; iMonths = cal . get ( Calendar . MONTH ) + 1 ; iDays = cal . get ( Calendar . DAY_OF_MONTH ) ; iHours = cal . get ( Calendar . HOUR_OF_DAY ) ; iMinutes = cal . get ( Calendar . MINUTE ) ; iSeconds = cal . get ( Calendar . SECOND ) ; year = int2string ( iYear , 4 ) ; months = int2string ( iMonths , 2 ) ; days = int2string ( iDays , 2 ) ; hours = int2string ( iHours , 2 ) ; minutes = int2string ( iMinutes , 2 ) ; seconds = int2string ( iSeconds , 2 ) ; if ( hoursTimezone != null ) { iHoursTimezone = iMinutesTimezone = 0 ; hoursTimezone = minutesTimezone = "00" ; isNegativeTimezone = false ; } } if ( fractionalSeconds != null ) { int zeroCount = 0 ; for ( int i = fractionalSeconds . length ( ) - 1 ; i >= 0 ; i -- ) { if ( fractionalSeconds . charAt ( i ) == '0' ) { zeroCount ++ ; } else { break ; } } if ( zeroCount == fractionalSeconds . length ( ) ) { fractionalSeconds = null ; } else if ( zeroCount > 0 ) { fractionalSeconds = fractionalSeconds . substring ( 0 , fractionalSeconds . length ( ) - zeroCount ) ; } } isNormalized = true ; }
normalizes this datetime object .
