Search code examples
javagwtcalendarsmartgwt

How to remove pm/am from smart gwt calendar


I made a calendar with smart GWT. Disabled both Day/Week tab and set the default to Month. I want to remove the am/pm time from the calendar. I don't need am/pm time because I'm using day as the smallest time unit.

Is there are any way to remove it? I was able to alter it by using:

calendar.setTimeFormatter(TimeDisplayFormat.TO24HOURTIME);

but there is no option to disable it, only to alter it.

Is this possible at all?


Solution

  • use:

    calendar.setTimeFormatter(TimeFormatter.TOSHORT24HOURTIME);
    

    Edit:

    What you want is not supported in the current formatter enum, but I think you can create some workaround (haven't try that although but give it a try).

    1. edit the Calendar.js and change it to something like this (see here):

      formatCellValue : function (value, record, rowNum, colNum, grid) {
           return "";
      }
      
    2. Create a copy of you new formatter, that is very like NativeTimeDisplayFormatter (it's final so you can't exteds it), and in the format method return you date format (in JS). then overload the setTimeFormatter so you'll be able to get your formatter, and do the same functionallity like the original one.