In my application I want to enter a date in an <input> field which is programatically created for a JSF page.
The creation of the input field looks like this:
// Input
String jsfValue = String.format("#{%s.item.%s}", getELClassname(), property.getKey());
ValueExpression valueExpression = JSFUtils.createValueExpression(jsfValue, property.getValue());
HtmlInputText input = (HtmlInputText) app.createComponent(HtmlInputText.COMPONENT_TYPE);
input.setId(property.getKey());
input.setValueExpression("value", valueExpression);
The property is an instance of java.util.Date and the <input> field is just an HtmlInputText component without any converter assigned to it.
When the <input> tag is rendered, then the following value can be seen for a date:
Tue Mar 11 18:31:20 CET 2014
If I know want to save the form, then the JSF page complains about the format of the date because it is not able to convert the input value to a java.util.Date.
Can someone tell me how I can create a converter programatically for a HtmlInputText component?
When I was using MyFaces for my application then the conversion was done automatically because I never had this problem before.
DateTimeConverter converter = (DateTimeConverter) application.createConverter(Date.class);
converter.setPattern(somePattern);
input.setConverter(converter);
The trick is to apply a DateTimeConverter to the dynamically created input field so that JSF knows how to convert the given String into a proper java.util.Date.
Here is a code sample:
HtmlInputText input = (HtmlInputText) app.createComponent(HtmlInputText.COMPONENT_TYPE);
...
DateTimeConverter converter = (DateTimeConverter) app.createConverter(DateTimeConverter.CONVERTER_ID);
converter.setPattern("mm/dd/yyyy");
input.setConverter(converter);
If other date formats are needed, you can take a look at Wikipedia: Date format by country.
Related
I have an element that accepts either a date value or a dateTime value. Right now the xsd for the element looks like this:
<xs:simpleType name="sTidpunkt">
<xs:union memberTypes="xs:date xs:dateTime"/>
</xs:simpleType>
How can I expand this to validate that the date part of the date or dateTime value is within a certain range? For example it has to be later than 1980-06-01 and earlier than 1990-06-01.
Thanks!
Reference information for XSD simple types is here: https://www.w3.org/TR/xmlschema-2/#dateTime
Based on that specification, I recommend the following:
Declare two new global simple type definitions: (e.g. myDate and myDateTime)
Add facets to those simple type definitions to limit the values in whatever way you require.
Change your memberTypes attribute to refer to the new simple types.
We have a readonly datepicker which shows date from specific date/month/year (dd/mm/yyyy) format. Now since its readonly, passing input is not possible. How can we select date from datepicker?
Above requirement has simple form to submit.
You can use a Post-Processor in order to extract the value from the HTML code of the response and store it into a JMeter Variable
The most suitable Post-Processor for HTML is CSS Selector Extractor, you can use CSS Selectors in order to access "interesting" parts of the response.
Here is the demo of fetching date from the input assuming CSS Selector Tester mode of the View Results Tree listener:
I need to format the in template of netSuite without changing the global date format.
As if I am able to change the date format in template then it will work for all the users.
Here is the reference for Freemarker's Date built-ins: https://freemarker.apache.org/docs/ref_builtins_date.html
In particular you'll want to look at the string() function, which let's you pass in a Date format.
I have a decision table (excel sheet) which has a column that contains date and time both in the format: 24/03/2017 11:44 AM. in the action section of decision table, I can parse this date as string and set it to a POJO setter but after receiving it, the pojo getter method is printing it in the format 43551.1683333336 which doesn't make any sense to me.
After trial and error, I found out that it was the problem with excel cell properties, because when I change the date in the cell to just: 24/02/2017 (remove timestamp), it's printing correctly on the java side. Anyone knows any workaround this? I don't want to use excel =DATE() like functions as well
DateHelper POJO:
String date;
String name; etc.
--getter setter here. nothing else--
rule in the decision table:
datehelper.setDate("$param");
FYI, other getters and setters are working fine.
Solved!
I changed the type of cell in excel sheet as text from date. and the parsed the incoming text with Java SimpleDateFormat parser.
I'm trying to set the format for a jquery datepicker element with the date format returned by Zend_Locale::getTranslationList('date', $locale);
My problem is zend returns the string 'dd/MM/yyyy' for the date format but jquery expects only 2 characters for the year ie 'dd/mm/yy', so it enters the year twice 20112011
Is there some option that can be passed to either zend or jquery to make them work in the same manner? I've read through the docs and can't seem to find anything
Many thanks for your help in advance!
I have used jquery date picker in python-django framework when I give date format as dd/mm/yyyy format it returns 20112011 then i have corrected it to dd/mm/yy and it returned 2011 only. you can specify in your datepicker css class to specify the date format as dd/mm/yy.
Iam not sure if this is what you're looking for but:
// use german local, change it to our needs :-)
$locale = new Zend_Locale('de_DE');
$result = Zend_Locale::getTranslationList('date', $locale);
// returns dd.MM.yy (german!)
echo $result['short'];