Code example for CharsetDecoder

Methods: decode

0
		} else { 
			// see: http://stackoverflow.com/questions/7376724 
			CharsetDecoder decoder = charset.newDecoder();
			CharBuffer charBuffer;
			try { 
				charBuffer = decoder.decode(ByteBuffer.wrap(data, offset, byteCount));
				return charBuffer.toString();
			} catch (Exception e) {
				return new String(data, offset, byteCount); // last-ditch effort - ignore the encoding
			} 
		} 
	} 
 
	public static String millisecondsToTimeString(long milliseconds, boolean includeMilliseconds) {
		// simulate the old behaviour of millisecondsToTimeString (showing the full millisecond value) 
		return millisecondsToTimeString(milliseconds, includeMilliseconds, true);
	} 
 
	public static String millisecondsToTimeString(long milliseconds, boolean includeMilliseconds, boolean highPrecision) {
		// overestimating is better than just rounding 
		int secondsIn = (int) Math.ceil(milliseconds / 1000);