Java Char Create toCharacter(Object obj)

Here you can find the source of toCharacter(Object obj)

Description

to Character

License

Open Source License

Declaration

public static char toCharacter(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static char toCharacter(Object obj) {
        return toCharacter(obj, (char) ' ');
    }/*  www. ja v a  2 s. c om*/

    public static char toCharacter(Object obj, char defaultValue) {
        if (obj == null) {
            return defaultValue;
        }
        String str = obj.toString().trim();
        if (str.length() == 0) {
            return defaultValue;
        }
        return (char) str.toCharArray()[0];
    }

    public static String toString(Object value) {
        if (value == null) {
            return "";
        }
        return value.toString().trim();
    }
}

Related

  1. toCharA(byte[] data)
  2. toCharacter(final String value)
  3. toCharacter(final String value)
  4. toCharacter(Object o)
  5. toCharacter(Object o)
  6. toCharacter(Object object)
  7. toCharacter(Object value)
  8. toCharacter(String input, char defaultValue)
  9. toCharacter(String str, String charset)