int intA = 0;1.intA =int.Parse(str);2.int.TryParse(str, out intA);3.intA = Convert.ToInt32(str);以上都可以,其中 1和3 需要try{}异常,2不需要. //TryParse() Usage1: int number; bool result = Int32.TryParse(value, out number); // return bool value hint y/n if (result) {…
public class TimeTwo { public static void main(String[] args) throws ParseException{ String s = "2018-08-12 12:02:23"; SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd MM:mm:ss"); try{ Date h = g.parse(s);// System.out.println(h);…