Skip to content

Help request: How to display the date and time in a cell at the same time? #280

@MaximMonakhov

Description

@MaximMonakhov

I would really appreciate some help, because I haven't figured out how to do this for half a day now.
I tried to do according to the cell API

Calendar calendar = Calendar.getInstance();
calendar.setTime(myDate);
cell.setDateValue(calendar);

But I'm losing hour and minute information.
This is what I get in the cell: 8.02.2024 00:00:00
If I try to set the time (cell.setTimeValue), I lose the date information in the cell (30.12.1899 16:50:12).

Then I tried to do it all on my own (actually tried to replicate the code in setDateValue or 'setTimeValue'), like this:

String date = new SimpleDateFormat(format).format(value);
TableTableCellElementBase element = cell.getOdfElement();
element.setOfficeValueTypeAttribute(OfficeValueTypeAttribute.Value.DATE.toString());
element.setOfficeDateValueAttribute(date);
cell.setDisplayText(date);

But that doesn't work either... Default DateTime in the cell 30.12.1899 00:00:00
Anyway, it would be great if someone could help me out, please...
I just need to get DateTime together

(im using 0.9 version btw)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions