commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38401] New: - at the org.apache.commons.lang.time.DurationFormatUtils, the formatPeriod function is return the wrong result
Date Thu, 26 Jan 2006 13:41:00 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGキ
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38401>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDキ
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38401

           Summary: at the org.apache.commons.lang.time.DurationFormatUtils,
                    the formatPeriod function is return the wrong result
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: yuhere@gmail.com


/**
 * lib: commons-lang-2.1.jar
 * 
 * this class run result.
 * Result:
 *    Date1->Date2=2006/01/26 18:47:34 000->2006/02/26 10:47:34 000===0000年01
月-1日 16:00:00 000
 *    Date1->Date2=2006/01/26 18:47:34 000->2006/02/26 10:47:34 000===0000/01/-
1 16:00:00 000
 * want result:
 *    Date1->Date2=2006/01/26 18:47:34 000->2006/02/26 10:47:34 000===0000年00月
30日 16:00:00
 *    Date1->Date2=2006/01/26 18:47:34 000->2006/02/26 10:47:34 
000===0000/00/30 16:00:00
 * 
 * 
 * the results are wrong.
 * 
 */

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang.time.DurationFormatUtils;

public class Test {
    
    static SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd 
HH:mm:ss SSS");


    public static void main(String[] args) {
        Date date1 = newDate(2006, 1, 26, 18, 47, 34);
        Date date2 = newDate(2006, 2, 26, 10, 47, 34);
        System.out.println("Date1->Date2=" + 
                formatter.format(date1) + "->" + formatter.format(date2) 
+ "===" +  
                DurationFormatUtils.formatPeriod(date1.getTime(), date2.getTime
(), "yyyy年MM月dd日 HH:mm:ss SSS") );

        System.out.println("Date1->Date2=" + 
                formatter.format(date1) + "->" + formatter.format(date2) 
+ "===" +  
                DurationFormatUtils.formatPeriod(date1.getTime(), date2.getTime
(), "yyyy/MM/dd HH:mm:ss SSS") );
    
    }

    public static Date newDate(int y, int m, int d, int h, int mi, int s) {
        Calendar calendar1 = Calendar.getInstance();
        calendar1.clear();
        calendar1.set(y, m - 1, d, h, mi, s);
        Date date1 = calendar1.getTime();
        return date1;
    }

}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message