views:

145

answers:

1

Hi!

In Calc I set a cell value to "2006/10/03 13:33:55.448" and Calc says it is Standard format. I'm doing this with Java and I want to set the format to "DD.MM.YY HH:MM:SS AM/PM":

XNumberFormatTypes xFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
int myDateFormat = xNumberFormats.addNew("DD.MM.YY HH:MM:SS AM/PM", defaultLocale);
XPropertySet cellRangePropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, cellRange);
cellRangePropSet.setPropertyValue("NumberFormat", new Integer(myDateFormat));

but the cell stil looks the same. Do I have to refresh the range so that the cell would display "03.10.06 01:33:55 PM"?

+1  A: 

Nope, I'm not doing that in any of my projects. The problem was that I imported a csv file in Calc and specified that the date column was of type Standard. Then I changed it to Date (YY/MM/DD) and the code magically worked. :)

kovica