public String printISO8601 ( ) { StringBuilder sb = new StringBuilder ( ) ; if ( _year > 0 ) { sb . append ( ( _year / 1000 ) % 10 ) ; sb . append ( ( _year / 100 ) % 10 ) ; sb . append ( ( _year / 10 ) % 10 ) ; sb . append ( _year % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( ( _month + 1 ) / 10 ) % 10 ) ; sb . append ( ( _month + 1 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( ( _dayOfMonth + 1 ) / 10 ) % 10 ) ; sb . append ( ( _dayOfMonth + 1 ) % 10 ) ; } long time = _timeOfDay / 1000 ; long ms = _timeOfDay % 1000 ; sb . append ( ' ' ) ; sb . append ( ( time / 36000 ) % 10 ) ; sb . append ( ( time / 3600 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( time / 600 ) % 6 ) ; sb . append ( ( time / 60 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( time / 10 ) % 6 ) ; sb . append ( ( time / 1 ) % 10 ) ; if ( ms != 0 ) { sb . append ( ' ' ) ; sb . append ( ( ms / 100 ) % 10 ) ; sb . append ( ( ms / 10 ) % 10 ) ; sb . append ( ms % 10 ) ; } if ( _zoneName == null ) { sb . append ( "Z" ) ; return sb . toString ( ) ; } // server/1471 - XXX: was commented out long offset = _zoneOffset ; if ( offset < 0 ) { sb . append ( "-" ) ; offset = - offset ; } else sb . append ( "+" ) ; sb . append ( ( offset / 36000000 ) % 10 ) ; sb . append ( ( offset / 3600000 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( offset / 600000 ) % 6 ) ; sb . append ( ( offset / 60000 ) % 10 ) ; return sb . toString ( ) ; }
Prints the time in ISO 8601