Widget: Make use of the date format of the project

I've created a small widget which allows users to quickly input dates. E.g. a user enters "0512" (ddmm) and on change the widget will convert it to the fifth of December and will display the date as "05/12/2017" in the text box.  The project I'm working on uses the Dutch language as default, so the default date format used by the default datepicker etc is dd-mm-yyyy . So I want to show the date as 05-12-2017 ("-" instead of "/" ). I can easily hardcode the "-" as seperator in  the widget but I would like to somehow retrieve the default format in the widget so I can use it to get the format from it. Is it possible to pass this information to the widget?
2 answers

Hi Stefan,

I haven't tried this before, but did once considered to include this in a custom widget.

Mendix makes use of the Dojo-toolkit, for localization (translation/formatting). You should be able to include the format-function in your widget and call this function.

Reference: https://dojotoolkit.org/reference-guide/1.10/dojo/date/locale/format.html#dojo-date-locale-format

require(["dojo/date/locale"], function(locale){
  locale.format(new Date(),{
    selector: "date",
    formatLength: "short"

Hopefully this helps a little bit! Please share your solution when you did succesfully implement this.


Mendix api has calls for that, you can start with




		getLocale: function() {
			if (kernel) {
				return kernel.locale;
			return mx.ui.getLocale();

Don't know what's the most actual yet.