Hi, All
OFBiz provides great date selectors. If the field is a date type, we can get string like 2009-09-17, if timestamp, the string shows like 2009-9-17 12:12:12.0. For the latter, I just want 2009-9-17 12:12:12, what I can do? Thank you. |
The form-widget could be extended to support this. In order to do so
you must: 0) Extend the current calendar (calendar_date_time.js) CalendarDateSelect class with an attribute hideMillis. Extend toFormattedString() to get it as an in parameter. Also create a new function called call_cal_nomillis which is similar to the ones at the bottom of the file to call the class with the hideMillis:true parameter. 1) Extend the <date-time/> tag in widget-form.xsd with a new attribute hide-millis. 2) Extend DateTimeField class in ModelFormField.java to capture the new attribute and provide getters/setters. 3) Extend HtmlFormRenderer.renderDateTimeField (in ofbiz/trunk r815165) it should be around line 588 and call the new js function from point 0). The new code should look like: if (shortDateInput) { writer.append("<a href=\"javascript:call_cal_notime(document."); } else if ("true".equals(dateTimeField.getHideMillis())) { writer.append("<a href=\"javascript:call_cal_nomillis(document."); } else { writer.append("<a href=\"javascript:call_cal(document."); } 4) Extend ObjectType.simpleTypeConvert() (ObjectType.java line 609) by adding code which will add ".00"; to str if the string is in the format without millis (can be detected with regexp similar to ".+\\s\ \d{1,2}+:\\d{2}+" (this regexp is for hidden seconds and millis) I hope this will help you. Regards, Todor Spasov On Sep 17, 2009, at 12:00 PM, Jack Liu wrote: > Hi, All > > OFBiz provides great date selectors. If the field is a date type, we > can > get string like 2009-09-17, if timestamp, the string shows like > 2009-9-17 12:12:12.0. > > For the latter, I just want 2009-9-17 12:12:12, what I can do? > > Thank you. > |
Thank you, Todor.
You helped me a lot. -----Original Message----- From: Todor Spasov [mailto:[hidden email]] Sent: 2009年9月17日 18:36 To: [hidden email] Subject: Re: OFBiz's Date selector The form-widget could be extended to support this. In order to do so you must: 0) Extend the current calendar (calendar_date_time.js) CalendarDateSelect class with an attribute hideMillis. Extend toFormattedString() to get it as an in parameter. Also create a new function called call_cal_nomillis which is similar to the ones at the bottom of the file to call the class with the hideMillis:true parameter. 1) Extend the <date-time/> tag in widget-form.xsd with a new attribute hide-millis. 2) Extend DateTimeField class in ModelFormField.java to capture the new attribute and provide getters/setters. 3) Extend HtmlFormRenderer.renderDateTimeField (in ofbiz/trunk r815165) it should be around line 588 and call the new js function from point 0). The new code should look like: if (shortDateInput) { writer.append("<a href=\"javascript:call_cal_notime(document."); } else if ("true".equals(dateTimeField.getHideMillis())) { writer.append("<a href=\"javascript:call_cal_nomillis(document."); } else { writer.append("<a href=\"javascript:call_cal(document."); } 4) Extend ObjectType.simpleTypeConvert() (ObjectType.java line 609) by adding code which will add ".00"; to str if the string is in the format without millis (can be detected with regexp similar to ".+\\s\ \d{1,2}+:\\d{2}+" (this regexp is for hidden seconds and millis) I hope this will help you. Regards, Todor Spasov On Sep 17, 2009, at 12:00 PM, Jack Liu wrote: > Hi, All > > OFBiz provides great date selectors. If the field is a date type, we > can > get string like 2009-09-17, if timestamp, the string shows like > 2009-9-17 12:12:12.0. > > For the latter, I just want 2009-9-17 12:12:12, what I can do? > > Thank you. > |
Free forum by Nabble | Edit this page |