Hi
I'm struggling to use a mask (with useMask) on a DateTimeItem. Unfortunately the month and day are mixed up. If I use DateUtil.setInputFormat( "DMY" ) then the format works as expected, but unfortunately I need a DataParser to parse the dates from different formats. If I'm just using the dateInputFormat and no DateParser, the order in the mask are correct, but the dates from the backends are not parsed correctly (they mostly come in yyyy-MM-dd).
Is there a solution for this or am I using the API the wrong way?
btw: I'm using SmartGWT 5.0 on Chrome (Ubuntu 15.10).
Thank you
I'm struggling to use a mask (with useMask) on a DateTimeItem. Unfortunately the month and day are mixed up. If I use DateUtil.setInputFormat( "DMY" ) then the format works as expected, but unfortunately I need a DataParser to parse the dates from different formats. If I'm just using the dateInputFormat and no DateParser, the order in the mask are correct, but the dates from the backends are not parsed correctly (they mostly come in yyyy-MM-dd).
Code:
DateDisplayFormatter dateFormatter = new DateDisplayFormatter() { @Override public String format( Date date ) { return DateTimeFormat.getFormat("dd.MM.yyyy").format(date); } }; DateDisplayFormatter dateTimeFormatter = new DateDisplayFormatter() { @Override public String format( Date date ) { return DateTimeFormat.getFormat("dd.MM.yyyy HH:mm").format(date); } }; // Sets the standard formats DateUtil.setNormalDateDisplayFormatter(dateFormatter); DateUtil.setShortDateDisplayFormatter(dateFormatter); DateUtil.setShortDatetimeDisplayFormatter(dateTimeFormatter); // simplified for this example. Parses different formats DateUtil.setDateParser(new DateParser() { @Override public Date parse(String dateString) { if (dateString.length() > 20 && dateString.contains("-")) { DateTimeFormat dateFormatter = DateTimeFormat .getFormat("yyyy-MM-dd HH:mm:ss.S"); return dateFormatter.parse(dateString); } else if (dateString.length() > 20) { DateTimeFormat dateFormatter = DateTimeFormat .getFormat("dd.MM.yyyy HH:mm:ss.S"); return dateFormatter.parse(dateString); } else { DateTimeFormat dateFormatter = DateTimeFormat .getFormat("yyyy-MM-dd"); return dateFormatter.parse(dateString); } } });
btw: I'm using SmartGWT 5.0 on Chrome (Ubuntu 15.10).
Thank you