Java - Write code to convert String To Int via Double.valueOf()

Requirements

Write code to convert String To Int via Double.valueOf()

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String sMt = "12312";
        System.out.println(convertStringToInt(sMt));
    }// w  w w .  j a v  a 2  s.co m

    public synchronized static int convertStringToInt(String sMt) {
        int result = 0;
        try {
            if (sMt != null) {
                result = Double.valueOf(sMt).intValue();
            }

        } catch (Exception e) {

        }
        return result;
    }
}