Forum Discussion
Hi,
Try with below code.
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.getTime().format("yyyy-MM-dd'T'HH:mm:ss")}
I use it in my XML so that can use date with current time
Thanks, dd1984!
- CByler8 years agoContributor
In case anyone is looking for examples in the future, I had several date formats I needed to test with. Below are the examples:
Current yyyy/mm/dd
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.getTime().format("yyyy-MM-dd'T'HH:mm:ss")}Current mm/dd/yyyy
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.getTime().format("MM/dd/yyyy")}Current mm/dd/yyyy Plus 1 Day
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.add(Calendar.DATE, 1);cal.getTime().format("MM/dd/yyyy")}Current mm-dd-yyyy Plus 1 Day
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.add(Calendar.DATE, 1);cal.getTime().format("MM-dd-yyyy")}Current mm/dd/yyyy Plus 1 Day with Timestamp
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.add(Calendar.DATE, 1);cal.getTime().format("MM/dd/yyyy'T'HH:mm:ss")}- nmrao8 years agoChampion Level 3
Well.
No need for such big expressions, which can be simplified as below(applicable for all of them)
Change from:
${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.getTime().format("yyyy-MM-dd
'T'HH:mm:ss")} To
${=new Date().format("yyyy-MM-dd'T'HH:mm:ss")}
- CByler8 years agoContributor
I was just trying to give back to the community. Way to make me rethink that...
Related Content
- 5 years agoKrishna_Kumar
- 2 years agoTestQA1
- 3 years agoloricotton