Sunday, December 6, 2009

Converting String to Date in Groovy

Recently I was looking for a simple way to convert a String object to a Date format in groovy..
below is the example.

In groovy, its just a one liner to make this happen

String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.


12 comments:

  1. thank you so much !!!!

    ReplyDelete
  2. Is there any way to convert '2017-02-08T02:01:00.000-08:00' string format to the same DateTime format, I do not want to disturb the ordering as I am querying the DB with date time

    ReplyDelete
  3. Really you have done great job,There are may person searching about that now they will find enough resources by your post
    python Training in Pune
    python Training in Chennai
    python Training in Bangalore

    ReplyDelete
  4. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Best Training Institute in Bangalore BTM. My Class Training Bangalore training center for certified course, learning on Software Training Course by expert faculties, also provides job placement for fresher, experience job seekers.
    Software Training Institute in Bangalore

    ReplyDelete
  5. Your topic is very nice and helpful to us … Thank you for the information you wrote.

    Learn Hadoop Training from the Industry Experts we bridge the gap between the need of the industry. Bangalore Training Academy provide the Best Hadoop Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
    Big Data Analytics Training in Bangalore
    Tableau Training in Bangalore
    Data Science Training in Bangalore
    Workday Training in Bangalore

    ReplyDelete
  6. This post is so interactive and informative.keep update more information...
    IELTS Coaching in Hyderabad
    IELTS Coaching in Bangalore

    ReplyDelete
  7. This post is so interactive and informative.keep update more information...
    Ethical Hacking Course in Tambaram
    Ethical Hacking Course in Chennai

    ReplyDelete