The Guava Libraries already contains that:
http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Defaults.html
Calling defaultValue will return the default value for any primitive type (as specified by the JLS), and null for any other type.
Use it like so:
import com.google.common.base.Defaults;
Defaults.defaultValue(Integer.TYPE); //will return 0