Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; public class Main { /** * parse value to byte */ public static byte toByte(Object value) { if (value instanceof Number) { return ((Number) value).byteValue(); } return value == null ? 0 : toByte(String.valueOf(value)); } /** * parse value to byte */ public static byte toByte(String value) { return TextUtils.isEmpty(value) ? 0 : Byte.parseByte(value); } }