Java - Write code to Check if the supplied value is a boolean

Requirements

Write code to Check if the supplied value is a boolean

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String value = "book2s.com";
        System.out.println(isBoolean(value));
    }//from w  w w.j  av a 2 s .c  o  m

    /**
     * Checks if the supplied value is a boolean
     * @param value String to be checked
     * @return true if the value is a boolean, false otherwise
     */

    public static boolean isBoolean(String value) {
        try {
            Boolean.valueOf(value);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}