public static String getW3CDate ( String d ) { if ( d . startsWith ( "D:" ) ) d = d . substring ( 2 ) ; StringBuffer sb = new StringBuffer ( ) ; if ( d . length ( ) < 4 ) return "0000" ; sb . append ( d . substring ( 0 , 4 ) ) ; //year d = d . substring ( 4 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( ' ' ) . append ( d . substring ( 0 , 2 ) ) ; //month d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( ' ' ) . append ( d . substring ( 0 , 2 ) ) ; //day d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( ' ' ) . append ( d . substring ( 0 , 2 ) ) ; //hour d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) { sb . append ( ":00Z" ) ; return sb . toString ( ) ; } sb . append ( ' ' ) . append ( d . substring ( 0 , 2 ) ) ; //minute d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) { sb . append ( ' ' ) ; return sb . toString ( ) ; } sb . append ( ' ' ) . append ( d . substring ( 0 , 2 ) ) ; //second d = d . substring ( 2 ) ; if ( d . startsWith ( "-" ) || d . startsWith ( "+" ) ) { String sign = d . substring ( 0 , 1 ) ; d = d . substring ( 1 ) ; String h = "00" ; String m = "00" ; if ( d . length ( ) >= 2 ) { h = d . substring ( 0 , 2 ) ; if ( d . length ( ) > 2 ) { d = d . substring ( 3 ) ; if ( d . length ( ) >= 2 ) m = d . substring ( 0 , 2 ) ; } sb . append ( sign ) . append ( h ) . append ( ' ' ) . append ( m ) ; return sb . toString ( ) ; } } sb . append ( ' ' ) ; return sb . toString ( ) ; }
Gives the W3C format of the PdfDate .