/** * Convert an object to a string. * The resulting string is limited to 32 characters. * @param o the object to convert * @return the resulting string * @ibm-api */ public static String toString( Object o ) { return toString(o,32); } /**
/** * Convert an object to a string. * The resulting string is limited to 32 characters. * @param o the object to convert * @return the resulting string * @ibm-api */ public static String toString( Object o ) { return toString(o,32); } /**
public static String toString(long value) { return StringUtil.toString(value); }
public static String toString(byte value) { return StringUtil.toString(value); }
public static String toString(short value) { return StringUtil.toString(value); }
public static String toString(int value) { return StringUtil.toString(value); }
public static String toString(float value) { return StringUtil.toString(value); }
public static String toString(java.math.BigInteger value) { return StringUtil.toString(value); }
public static String toString(int year, int month, int day, int hour, int minute, int second, int millis) { return StringUtil.format( "{0}-{1}-{2}", //$NON-NLS-1$ StringUtil.toString(year), StringUtil.toString(month), StringUtil.toString(day)) + StringUtil.format( " {0}:{1}:{2}", //.{3}", //$NON-NLS-1$ StringUtil.toString(hour), StringUtil.toString(minute), StringUtil.toString(second) ); // StringUtil.toString(millis)); } public static int getYear( long dt ) {
public static String toString(int year, int month, int day, int hour, int minute, int second, int millis) { return StringUtil.format( "{0}-{1}-{2}", //$NON-NLS-1$ StringUtil.toString(year), StringUtil.toString(month), StringUtil.toString(day)) + StringUtil.format( " {0}:{1}:{2}", //.{3}", //$NON-NLS-1$ StringUtil.toString(hour), StringUtil.toString(minute), StringUtil.toString(second) ); // StringUtil.toString(millis)); } public static int getYear( long dt ) {
if( i!=0 ) buf.append( ", " ); //$NON-NLS-1$ if( za!=null ) { buf.append( toString(za[i]) ); } else if( ca!=null ) { buf.append( '\'' ); buf.append( '\'' ); } else if( ba!=null ) { buf.append( toString(ba[i]) ); } else if( sa!=null ) { buf.append( toString(sa[i]) ); } else if( ia!=null ) { buf.append( toString(ia[i]) ); } else if( la!=null ) { buf.append( toString(la[i]) ); } else if( fa!=null ) { buf.append( toString(fa[i]) ); } else if( da!=null ) { buf.append( toString(da[i]) ); } else if( oa!=null ) { buf.append( toString(oa[i]) );
if( i!=0 ) buf.append( ", " ); //$NON-NLS-1$ if( za!=null ) { buf.append( toString(za[i]) ); } else if( ca!=null ) { buf.append( '\'' ); buf.append( '\'' ); } else if( ba!=null ) { buf.append( toString(ba[i]) ); } else if( sa!=null ) { buf.append( toString(sa[i]) ); } else if( ia!=null ) { buf.append( toString(ia[i]) ); } else if( la!=null ) { buf.append( toString(la[i]) ); } else if( fa!=null ) { buf.append( toString(fa[i]) ); } else if( da!=null ) { buf.append( toString(da[i]) ); } else if( oa!=null ) { buf.append( toString(oa[i]) );
/** * Convert an integer to an Hexa string and pad the result with '0' * @param value the int to convert * @param nChars the number of characters of the result * @return the resulting string * @ibm-api * @throws NumberFormatException if nChars is less that the actual number of characters needed */ public static final String toUnsignedHex( int value, int nChars ) { FastStringBuffer b = new FastStringBuffer(); //String s = Integer.toHexString(value); for( int i=7; i>=0; i-- ) { int v = (value >>> (i*4)) & 0x0F; if( b.length()>0 || v!=0 || i<nChars || i==0 ) { b.append(hexChar(v)); } } if( nChars>0 && b.length()>nChars ) { throw new NumberFormatException( StringUtil.format( "Hexadecimal number {0} too big to fit in '{1}' characters", //$NLS-StringUtil.StringUtil.HexNumTooBig.Exception-1$ StringUtil.toString(value), StringUtil.toString(nChars) )); } return b.toString(); } public static final char hexChar(int v) {
/** * Convert an integer to an Hexa string and pad the result with '0' * @param value the int to convert * @param nChars the number of characters of the result * @return the resulting string * @ibm-api * @throws NumberFormatException if nChars is less that the actual number of characters needed */ public static final String toUnsignedHex( int value, int nChars ) { FastStringBuffer b = new FastStringBuffer(); //String s = Integer.toHexString(value); for( int i=7; i>=0; i-- ) { int v = (value >>> (i*4)) & 0x0F; if( b.length()>0 || v!=0 || i<nChars || i==0 ) { b.append(hexChar(v)); } } if( nChars>0 && b.length()>nChars ) { throw new NumberFormatException( StringUtil.format( "Hexadecimal number {0} too big to fit in '{1}' characters", //$NLS-StringUtil.StringUtil.HexNumTooBig.Exception-1$ StringUtil.toString(value), StringUtil.toString(nChars) )); } return b.toString(); } public static final char hexChar(int v) {