做到这两点就ok了,如代码所示
- public class Text {
- //1.对于过时的方法可以在这里加上一个注解。避免了代码不能被编译,这样就ok了
- @SuppressWarnings("deprection")
- public static void main(String[] args){
- //2.Date类中的getSeconds()不是静态方法,不能直接被调用,如Date.getSeconds();应该new一个对象,再调用
- Date d = new Date();
- int seconds = d.getSeconds();
- System.out.println(seconds);
- }
- }
复制代码 |