⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdate.java

📁 java base64
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        // Little Richard was born on 1932-12-05
        final BigDate birthDate = new BigDate( 1932, 12, 5 );
        final BigDate today = BigDate.localToday();
        final int[] age = BigDate.age( birthDate, today );
        final int nextAge = age[ 0 ] + 1;
        BigDate nextBirthday = new BigDate( 1932 + nextAge, 12, 5 );
        System.out.println( "Little Richard will be " + nextAge + " on " + nextBirthday.toString() + "." );
        }
        sep();
        {
        // How old was Bush's Press secretary Scott McClellan when he married
        // Jill Martinez on 2003-11-22.
        // Scotty was born on 1968-02-14.
        BigDate birthDate = new BigDate( 1968, 2, 14 );
        BigDate wedding = new BigDate( 2003, 11, 22 );
        int[] age = BigDate.age( birthDate, wedding );
        System.out
                .println( "Scott McClelland was "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days old when he married Jill Martinez." );
        }

        sep();

        {
        // Dr. Paul Norman was killed in plane crash
        // on the Sunday before Friday 2004-07-02. What date was that?
        BigDate deathDate = new BigDate( 2004, 7, 2 );
        deathDate
                .setOrdinal( deathDate.getOrdinal() - 5/* Friday */ + 0
                        /* Sunday */ );
        System.out
                .println( "Dr. Paul Norman was killed in a plane crash on "
                          + deathDate
                          + "." );
        }

        sep();

        {
        // How much time elapsed after Hitler died before George W. Bush was
        // born.

        BigDate hitler = new BigDate( 1945, 5, 1 );
        BigDate bush = new BigDate( 1946, 7, 6 );
        int[] age = BigDate.age( hitler, bush );
        System.out
                .println( "George W. Bush was born "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days after Hitler died on 1945-05-01" );
        System.out
                .println( "or "
                          + ( bush.getOrdinal() - hitler.getOrdinal() )
                          + " days." );
        }

        sep();

        {
        // Precisely how old was Hillary Clinton (born 1947-10-26)
        // when Sir Edmund Hillary climbed
        // mount everent in 1953-05-29 in years, months and days
        BigDate birthDate = new BigDate( 1947, 10, 26 );
        BigDate climb = new BigDate( 1953, 5, 29 );
        int[] age = BigDate.age( birthDate, climb );
        System.out
                .println( "Hillary Clinton was "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days old when Sir Edmund Hillary climbed Mount Everest on 1953-05-29" );
        System.out
                .println( "or "
                          + ( climb.getOrdinal() - birthDate.getOrdinal() )
                          + " days." );
        }

        sep();

        {
        // What day of the week was Jesus born on?
        // assume Jesus was born on December 25, 0001.
        // Scholars assure us he was NOT actually born then.
        int dayOfWeek = BigDate.dayOfWeek( BigDate.toOrdinal( 1, 12, 25 ) );
        String[] daysOfTheWeek = {
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday" };
        String dayName = daysOfTheWeek[ dayOfWeek ];
        System.out.println( "Jesus was born on a " + dayName + "." );
        }

        sep();

        {
        // How much time elapsed between December 25 4 BC and April 30, 28
        // AD
        BigDate fromDate = new BigDate( -4, 12, 25 );
        BigDate toDate = new BigDate( 28, 4, 30 );
        System.out.println( "How long did Jesus live?" );
        System.out
                .println( toDate.getOrdinal() - fromDate.getOrdinal()
                          + " days elapsed between 0004/12/25 BC and 0028/04/30 AD," );
        int[] age = BigDate.age( fromDate, toDate );
        System.out
                .println( "or put another way, "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days." );
        }

        sep();

        {
        // Precisely how old is George W. Bush, in years, months and days
        // George W. Bush was born on July 6. 1946.
        BigDate birthDate = new BigDate( 1946, 7, 6 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( birthDate, today );
        System.out
                .println( "Today, George W. Bush is "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days old." );
        }

        sep();

        {
        // Precisely how old is Saddam Hussein, in years, months and days
        // Saddam Hussein was born on April 28, 1937.
        BigDate birthDate = new BigDate( 1937, 4, 28 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( birthDate, today );
        System.out
                .println( "Today, Saddam Hussein would be "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days old." );
        }

        sep();

        {
        // How long did WWII last?
        BigDate startDate = new BigDate( 1939, 9, 1 );
        BigDate endDate = new BigDate( 1945, 8, 15 );
        int[] age = BigDate.age( startDate, endDate );
        System.out
                .println( "World War II raged one for "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days." );
        }

        sep();

        {
        // How long has the Afghan war waged?
        BigDate startDate = new BigDate( 2001, 10, 7 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( startDate, today );
        System.out
                .println( "The Afghan war has raged one for "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days." );
        }

        sep();

        {// How long has the Iraq war waged?
        BigDate startDate = new BigDate( 2003, 3, 20 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( startDate, today );
        System.out
                .println( "The Iraq war has raged one for "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days." );
        }

        {
        // How long has the Iraq war waged since Saddam was captured
        BigDate startDate = new BigDate( 2003, 12, 13 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( startDate, today );
        System.out
                .println( "The Iraq war has raged one for "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days since Saddam was captured." );
        }

        sep();

        {
        // How Many days after bin Laden's last documented meeting with the
        // CIA
        // was the World Trade attack?
        BigDate fromDate = new BigDate( 2001, 7, 1 );// 2001-07-01
        BigDate toDate = new BigDate( 2001, 9, 11 );// 2001-09-11
        System.out
                .println( "The World Trade attack occurred "
                          + ( toDate.getOrdinal() - fromDate.getOrdinal() )
                          + " days after Osmama bin Laden's last meeting with the CIA." );
        }

        sep();

        {
        // How long ago was the World Trade Center destroyed?

        // The attack was 2001-09-11.
        BigDate hitDate = new BigDate( 2001, 9, 11 );
        BigDate today = BigDate.localToday();
        int[] age = BigDate.age( hitDate, today );
        System.out
                .println( "The World Trade center was destroyed "
                          + age[ 0 ]
                          + " years and "
                          + age[ 1 ]
                          + " months and "
                          + age[ 2 ]
                          + " days ago." );
        }

        sep();

        {
        // How long did it take Bush to give up trying to catch bin Laden.
        // The attack was 2001-09-11.
        // On 2002-03-13 Bush announced:
        // I don't know where he is. I have no idea and I really don't care.
        // It's not that important. It's not our priority.
        BigDate hitDate = new BigDate( 2001, 9, 11 );
        BigDate giveUpDate = new BigDate( 2002, 3, 13 );
        int[] patience = BigDate.age( hitDate, giveUpDate );
        System.out
                .println( "Bush officially gave up chasing bin Laden after "
                          + patience[ 0 ]
                          + " years,  "
                          + patience[ 1 ]
                          + " months and "
                          + patience[ 2 ]
                          + " days." );
        }

        sep();

        {
        // What was the date and day of week 72 days prior to Lincoln's
        // assassination?
        BigDate assassinDate = new BigDate( 1865, 4, 18 );// 1865-04-18
        BigDate priorDate = new BigDate( assassinDate.getOrdinal() - 72 );
        int dayOfWeek = priorDate.getDayOfWeek();
        final String[] daysOfTheWeek = {
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday" };
        System.out
                .println( "72 days prior to Lincoln's assassination was "
                          + priorDate.toString()
                          + ", a "
                          + daysOfTheWeek[ dayOfWeek ] );
        }

        sep();

        {
        // how long has it been since since John F. Kennedy was
        // assassinated?
        // John F. Kennedy was assassinated on November 22, 1963
        System.out
                .println( "John F. Kennedy was assassinated "
                          + ( BigDate.localToday().getOrdinal()
                              - BigDate.toOrdinal( 1963, 11, 22 ) )
                          + " days ago." );
        }

        sep();

        {
        // How long after Martin Luther King's assassination
        // was Bobby Kennedy assassinated?
        // MLK was assassinated 1968-04-04
        // RK was assassinated 1968-06-05 according to http://foia.fbi.gov/foiaindex/rfkasumm.htm
        System.out
                .println( "Robert Kennedy was assassinated "
                          + ( BigDate.toOrdinal( 1968, 6, 5 )
                              - BigDate.toOrdinal( 1968, 4, 4 ) )
                          + " days after Martin Luther King." );
        }

        sep();

        {
        // How old would Martin Luther King be if he were still alive today?
        // MLK was born 1929-01-15, celebrated 3rd monday in January
        BigDate mlk = new BigDate( 1929, 1, 15 );
        BigDate today = BigDate.localToday();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -