Forum Discussion

CByler's avatar
CByler
Contributor
4 years ago
Solved

Java code snippet no longer working to create dates in 3.3.2, worked fine in 3.3.1 and prior builds

I have been using the following custom property for years to create dates which I then pass for my insertion of transactions in my rest web service calls.  The below example has always created the da...
  • CByler's avatar
    CByler
    4 years ago

    The custom property worked perfectly! Let me ask one more thing. With the old java, I could modify the dates such as:

     

    Same Day
    ${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.getTime().format("MM/dd/yyyy")}

    Future Date
    ${=import javax.xml.datatype.DatatypeFactory; def cal = Calendar.instance;cal.add(Calendar.DATE, 1000);cal.getTime().format("MM/dd/yyyy")}

     

    Is that possible using the SimpleDate snippets?

  • PrathapR's avatar
    PrathapR
    4 years ago

    1) Future date custom property with Local Date class: 

    ${= import java.time.LocalDate; LocalDate.now().plusDays(1).format(java.time.format.DateTimeFormatter.ofPattern("MM/dd/yyyy"))}

    or

    ${=java.time.LocalDateTime.now().plusDays(1).format(java.time.format.DateTimeFormatter.ofPattern("MM/dd/yyyy"))}

     

    2) Future Date in groovy with Simple Date Format:

    import groovy.time.TimeCategory
    import java.text.SimpleDateFormat

     

    use(TimeCategory) {
    def time = new Date()+ 1.days
    date = new SimpleDateFormat ("MM/dd/yyyy").format(time)

    }