/** * @title useful_code_snippets * @url http://jpad.io/example/1O/useful-code-snippets */ // Converting int to String and Strings to int // Integer to numeric string String numericString = String.valueOf(2); // Numeric string to an int int integer = Integer.parseInt(numericString); Dump(numericString, "Numeric String"); Dump(integer, "Int"); // Converting String to date in Java String myStringDate = "21.09.2018"; SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" ); Date date = format.parse( myStringDate ); Dump(date, "Date"); // Converting Java util.Date to sql.Date SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "dd/MM/yyyy" ); Date utilDate = simpleDateFormat.parse("21/09/2018"); java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); Dump(utilDate, "Util Date"); Dump(sqlDate, "SQL Date"); // Get name of current method String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); Dump(methodName, "Current Method Name");