Forum Discussion

AAB's avatar
AAB
Regular Contributor
5 years ago
Solved

Groovy How to change DateTime as dd-MM-yyyy

Hello,   I have to compare 2 different files that I'm doing with a Groovy script. For the first file, the date is as dd-MM-yyyy. The second file is in yyyy-MM-dd. How can I change the second ...
  • AAB's avatar
    AAB
    5 years ago

    nmrao  thanks for your response.

    I did it this way:

     

    //------------Concepts - Validity - Dates
    def convertDate(date) {
      SimpleDateFormat formatFromApi = new SimpleDateFormat("yyyy-MM-dd")
      Date parsedDate = formatFromApi.parse(date)
    
      SimpleDateFormat formatToGolden = new SimpleDateFormat("dd/MM/yyyy")
      String goldenDate = formatToGolden.format(parsedDate)
      return goldenDate
    }

    Kind regards,

    AboveAndBeyond