incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devin Han (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ODFTOOLKIT-296) ODFTable.OdfTableCell.getDateValue() ignores times in datefields
Date Tue, 22 Nov 2011 09:32:39 GMT

    [ https://issues.apache.org/jira/browse/ODFTOOLKIT-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13154972#comment-13154972
] 

Devin Han commented on ODFTOOLKIT-296:
--------------------------------------

Hi Sebastian,

There are two ways to resolve this issue.
1. if you only need the string of the date value, you can use ODFTable.OdfTableCell.getDisplayText()
to replace getDateValue(). It's easy and no need patch.
2. if you prefer to get the Calendar object, we need a patch to realize it. 
    Now, in getDateValue(), ODFDOM uses DEFAULT_DATE_FORMAT = "yyyy-MM-dd" to parse date string.
That's the reason that this issue. On the other hand, it's impossible to set a  DEFAULT_DATE_FORMAT,
which is suitable for all of the condition. The best way is that give this right back to user.
So I suggest to add the following two mehods in Cell class.
        
        /**
	 * Get the cell date value as Calendar.
	 * <p>
	 * Throw IllegalArgumentException if the cell type is not "date".
	 * @param format the <code>format</code> must follow the encoding 
	 * rule of {@link java.text.SimpleDateFormat <code>java.text.SimpleDateFormat</code>}
	 * 
	 * @return the Calendar value of cell
	 * @throws IllegalArgumentException  an IllegalArgumentException will be thrown, if the cell
type is not "date".
	 */
	public Calendar getDateValue(String format);

	/**
	 * Set the cell value as a date, and set the value type to be "date".
	 * 
	 * @param date	the value of {@link java.util.Calendar java.util.Calendar} type.
	 * @param format the <code>format</code> must follow the encoding 
	 * rule of {@link java.text.SimpleDateFormat <code>java.text.SimpleDateFormat</code>}
	 * 
	 */
	public void setDateValue(Calendar date, String format);

        /**
	 * Get the cell value as {@link java.util.Calendar java.util.Calendar}.
	 * <p>
	 * Throw exception if the cell type is not "time".
	 * @param format the <code>format</code> must follow the encoding 
	 * rule of {@link java.text.SimpleDateFormat <code>java.text.SimpleDateFormat</code>}
	 * 
	 * @return the Calendar value of cell
	 * @throws IllegalArgumentException  an IllegalArgumentException will be thrown if the cell
type is not time.
	 */
	public Calendar getTimeValue(String format) ;

	/**
	 * Set the cell value as a time and set the value type to be "time" too.
	 * 
	 * @param time  the value of {@link java.util.Calendar java.util.Calendar} type.
	 * @param format the <code>format</code> must follow the encoding 
	 * rule of {@link java.text.SimpleDateFormat <code>java.text.SimpleDateFormat</code>}
	 * 
	 * @throws IllegalArgumentException   If input time is null, an IllegalArgumentException
exception will be thrown.
	 */
	public void setTimeValue(Calendar time, String format);

The convenient API of ODFDOM is not supported anymore, which will be replaced by Simple API
in the future.
I suggest you use Simple API replace ODFDOM convenient API. It has more powerful functions,
and you will be interested it. Please reference the homepage: http://incubator.apache.org/odftoolkit/simple/index.html

My patch is based on Simple API. I will send a private jar based on ODFDOM to you.

Devin
                
> ODFTable.OdfTableCell.getDateValue() ignores times in datefields 
> -----------------------------------------------------------------
>
>                 Key: ODFTOOLKIT-296
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-296
>             Project: ODF Toolkit
>          Issue Type: Improvement
>            Reporter: Devin Han
>            Assignee: Devin Han
>              Labels: ODFDOM
>
> A user report this issue in ODF Toolkit Union user mail list, but we have not maintained
that list, so forward it here. 
> The following content is copied from: http://odftoolkit.org/bugzilla/show_bug.cgi?id=361
> ---------------------------------------------
> For table-cells, which are formated as "DATE" with a format including the
> day-time (e.g. MM/DD/YYYY HH:MM:SS), the time value is ignored when importing
> the this cell with 
> ODFtable.ODFcell.getDateValue()
> => 12/31/2011 12:13:14    is imported into the calendar-object as 
> => 12/31/2011 00:00:00
> Sebastian
> ---------------------------------------------------
> Devin

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message