[Solved] Changing the date format

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
kovi
Posts: 6
Joined: Fri Jan 09, 2009 2:26 pm

[Solved] Changing the date format

Post by kovi »

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"?
Last edited by Villeroy on Tue Jan 13, 2009 5:50 pm, edited 1 time in total.
Reason: Tagged [Solved]
OOo 3.0.X on Ubuntu 8.x
kovi
Posts: 6
Joined: Fri Jan 09, 2009 2:26 pm

Re: Changing the date format

Post by kovi »

Since the data was imported via CSV file I had to specify that a column is of type 5 in FilterOptions.
OOo 3.0.X on Ubuntu 8.x
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing the date format

Post by Villeroy »

kovi wrote:Since the data was imported via CSV file I had to specify that a column is of type 5 in FilterOptions.
So you had no numbers in the cells and number formatting was pointless with text values. This is why I was clueless about what could be wrong with your code.
Thank you for resolving this by your own.

moderation: I'll tag this as [Solved]
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply