欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle.jbo.domain.Datejava.utils.Datejava.sql.Date时间转换测试

程序员文章站 2022-05-14 10:39:42
oracle.jbo.domain.datejava.utils.datejava.sql.date时间转换测试 public static void main(string[] args)...

oracle.jbo.domain.datejava.utils.datejava.sql.date时间转换测试

 public static void main(string[] args) {
        string time = "2014-02-19";
        simpledateformat df = new simpledateformat("yyyy-mm-dd");
        java.sql.timestamp jstdate =
            new java.sql.timestamp(system.currenttimemillis());

        java.util.date currentjudate =
            new java.util.date(system.currenttimemillis());
        oracle.jbo.domain.date currentojddate =
            new oracle.jbo.domain.date(jstdate);
        system.out.println(jstdate);
        system.out.println(currentjudate);
        system.out.println(new java.util.date(currentojddate.timestampvalue().gettime()));
        system.out.println(currentojddate);
        system.out.println("get1time" + jstdate.gettime() + "\nget2time" +
                           currentjudate.gettime() + "\nget3time" +
                           currentojddate.timestampvalue().gettime());


        try {
            java.util.date judate = df.parse(time);
            system.out.println("judate" + judate);
            oracle.jbo.domain.date ojddate =
                new oracle.jbo.domain.date(new java.sql.timestamp(judate.gettime()));
            system.out.println(ojddate);
            system.out.println("judate.gettime()=" + judate.gettime());
            java.util.date judate2 =
                new java.util.date(ojddate.timestampvalue().gettime());
            system.out.println("ojddate.timestampvalue().gettime()" +
                               ojddate.timestampvalue().gettime());
            system.out.println(judate2);
            string time2 = null;
            time2 = df.format(judate2);
            system.out.println(time2);
        } catch (exception e) {
            system.out.println("exception");
            e.printstacktrace();
        }
    }