How to change the setting of DialogComponentDate or DateInputDialog?

i am using DialogComponentDate now but i want to show the date and hide the time part.

I also want to set default date as current date, where i can config those features ? Because i can’t set in SettingsModelDate.

Then i tried to use DateInputDialog and i found

new DateInputDialog(DateInputDialog.Mode. NOTIME );

which fit my need. But how this work with addDialogComponent()? because i don’t know how to put this on my panel like cast to DialogComponent. Thank you

Hi @eaton1632,

Have you looked into org.knime.time.util.DialogComponentDateTimeSelection? This is the new dialog component which was used in the new Date&Time nodes. There you can set the DisplayOption to SHOW_DATE_ONLY. If you want to have the current date set when opening the dialog, you need to specify this during loading the dialog settings.

Cheers,
Simon

1 Like

Did not find the class DialogComponentDateTimeSelection in https://www.knime.com/docs/api/index.html
and in Eclipse SDK

THANKS

I use SettingsModelDate and set the default time with the following code,but not work

@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
	/*
	 * Load (valid) settings from the NodeSettings object. It can be safely assumed that
	 * the settings are validated by the method below.
	 * 
	 * The SettingsModel will handle the loading. After this call, the current value
	 * (from the view) can be retrieved from the settings model.
	 */
	m_numberFormatSettings.loadSettingsFrom(settings);
	startDateSettings.setTimeInMillis(new Date().getTime());
	startDateSettings.loadSettingsFrom(settings);
}

Hi @lou,

It’s this class: knime-base/org.knime.time/src/org/knime/time/util/DialogComponentDateTimeSelection.java at master · knime/knime-base · GitHub
Did you setup the sdk correctly? Follow the instructions here GitHub - knime/knime-sdk-setup: KNIME Analytics Platform - SDK Setup .

What does not work?

Cheers,
Simon

My sdk version is

Not work:the date component default did not update with my init value.

thanks

The class is in knime-base, not in knime-core.

You are loading the settings after you have set the value, i.e., you overwrite your value by loading the settings. I think that’s the issue.

According to the document GitHub - knime/knime-sdk-setup: KNIME Analytics Platform - SDK Setup did not find how to import the knime-base jar

You mean set the default date must within which method?

You don’t need any jar at all. All you need is to set the target platform as described there. The target platform brings all these dependencies and you will be able to use the DialogComponentDateTimeSelection class.

Did you take a look at this blog post The Five Steps to Writing Your Own KNIME Extension | KNIME or at this documentation Create a New Java based KNIME Extension? They might help you to understand how to work with default dialog components.

Cheers,
Simon

1 Like

thanks i will try reload target platform.
by the way,could you give me some suggestion on how to set the init date on

org.knime.core.node.defaultnodesettings.DialogComponentDate


I set the init date value within configure method

@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
	LogUtil.printLog("configure");
	startTimeSetting.setTimeInMillis(new Date().getTime());
	endTimeSetting.setTimeInMillis(new Date().getTime());
	return new DataTableSpec[] { null };
}

but open configure dialog the init date always 1970-01-01

image

Where is the GitHub - knime/knime-core: KNIME Analytics Platform API DOC?

I changed the target to target-complete and core-base.jar is in the dependency,but class
knime-base/org.knime.time/src/org/knime/time/util/DialogComponentDateTimeSelection.java at master · knime/knime-base · GitHub
not found.

image

The API documentation is in the code. It is open source, so you can just have a look at it. I don’t think we have a website which lists the API.

Hard to guess what the problem is. The only advice I can give is to double check that you didn’t skip any of the steps in the instruction and that all the dependencies are correctly set up.

1 Like

there is not org.knime.time package in my project knime-base jar

image

Here is the solution knime-base.jar not including all source code at github - #2 by gab1one