[DateField] Set Hours and Minutes to 0 in the Calendar ?

Hello,

I can’t get something working to set the Time (Hours and Minutes) to 0 in the Calendar instance of the DateField. In fact, the method getCalendar() is private so I can’t override it. It calls Calendar.getInstance()
and this method initialize the default Date value with the current Date and Time.

I tried to copy/paste the code of DateField into a new class in my project but it says "Widgetset does not contain implementation for […]
". So I managed to put the code into a widget but the same issue occured.
I also tried to play with the set/getValue method but I got nothing relevant.

Any idea how I can achieve that ?

Many thanks.

You might want to check out Joda-Time. It makes many Date/Calendar-related things a lot easier.

Thanks for your answer.

In fact, I use Joda-Time (DateTime to be more precise) in my aplication. I already looked for plug-in that handle it but no plug-in suits to my needs. Some of plug-ins manages Joda-Time but my problem is still the same…

Ah, sorry, I suppose I misread the question earlier. I meant that for converting the values outside of the field, for example in a custom converter, in which case you might not need to alter the DateField at all. If your problem is mainly about not getting a custom widget to work, did you check out the
wiki
articles about them (5th category on the page)? Sounds like your widget doesn’t get included when you recompile the widgetset (do you get any errors?), which might be caused by any number of reasons, but it would be a good start to make sure that your gwt.xml contains what it should and that other basics are in place.

Ok, I tried this but I don’t know how to do. My plugin must be mavenized so I created a new Project with the mvn command :

mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-widget -DarchetypeVersion=7.0-SNAPSHOT -Dpackaging=war

Now I have a project structured like this :

|-- my-datefield-root
  |-- my-datefield
      |-- client
          |-- MyDateFieldClientRpc.java
          |-- MyDateFieldConnector.java
          |-- MyDateFieldServerRPC.java
          |-- MyDateFieldState.java
          |-- MyDateFieldWidget.java
      |-- MyDateField.java
  |-- my-datefield-demo
      |-- DemoUI.java

I’m stuck here : Where can I put the code of DateField ? As a reminder, my goal is simply to replace the code of the private method. getCalendar()

Again, thank you.

I’m afraid I’ve never created an add-on with maven – you might want to make a new post with that in the subject line so someone with some actual knowledge on the subject would spot it.

In the meantime I’m assuming you gave me the contents of main/java, and since you didn’t mention it in that listing I suppose you should have a .gwt.xml within your main/resources folder in package my-datefield-root.my-datefield (if it were withing main/java the package should be the same), and when you compile the widgetset it should appear in WebContent/VAADIN/widgetsets/ and in main/webapp/VAADIN/widgetsets (if you are using Eclipse and Project Explorer view to inspect your project structure you need to switch to Navigator view to see that), the latter of which is referenced from your pom.xml.

Is this correct?

In fact the structure I gave contains the main/java and main/resources folders. I created a new post as you suggest me : https://vaadin.com/forum#!/thread/4986822

Thank you for your help.