-
-
-
-
-
- public class Test {
-
- public static void main(String[] args) {
- new Test().controller();
- }
-
- public void controller() {
- try {
- service();
- } catch (MyException e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- }
-
- public void service() throws MyException {
- dao();
- }
-
- public void dao() throws MyException {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- try {
- sdf.parse("20110412");
- } catch (ParseException e) {
- throw new MyException("格式化日期错误!", e);
- }
- }
-
- }
- public class MyException extends RuntimeException {
-
- public MyException() {
- super();
- }
-
- public MyException(String msg) {
- super(msg);
- }
-
- public MyException(Throwable e) {
- super(e);
- }
-
- public MyException(String msg, Throwable e) {
- super(msg, e);
- }
-
- }
http://blog.youkuaiyun.com/zq9017197/article/details/6320083