{"id":80,"date":"2013-01-23T06:12:23","date_gmt":"2013-01-23T06:12:23","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=80"},"modified":"2022-02-03T11:25:06","modified_gmt":"2022-02-03T17:25:06","slug":"really-common-groovy-and-java-code-for-bonita","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/","title":{"rendered":"Really common groovy and Java code for Bonita"},"content":{"rendered":"<p>I seem to use this code all the time so I published it for others to use.<\/p>\n<h2>Java Date to MySQL<\/h2>\n[cc lang=&#8221;groovy&#8221;]\njava.util.Date dt = new java.util.Date();<br \/>\njava.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;);<br \/>\nString currentTime = sdf.format(dt);<br \/>\n[\/cc]\n<h2>date MySQL string to Java:<\/h2>\n[cc lang=&#8221;groovy&#8221;]\nimport java.text.SimpleDateFormat;<br \/>\nimport java.text.DateFormat;<br \/>\nString target = &#8220;2012-02-01 20:29:30&#8221;;<br \/>\nDateFormat df = new SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;, Locale.ENGLISH);<br \/>\nDate result = df.parse(target);<br \/>\nprintln result;<br \/>\n[\/cc]\n<h2>Debugging to the Bonita Log<\/h2>\n[cc lang=&#8221;groovy&#8221;]\nimport org.slf4j.Logger;<br \/>\nimport org.slf4j.LoggerFactory;<br \/>\nLogger LOGGER = LoggerFactory.getLogger(this.getClass());<br \/>\nLOGGER.error(&#8220;Your String Here&#8221;);<br \/>\n[\/cc]\n<h2>Groovy SQL in place of MySQL connector which is more of a hassle than a help<\/h2>\n[cc lang=&#8221;groovy&#8221;]\nimport groovy.sql.Sql import java.sql.Connection;<br \/>\nimport java.sql.DriverManager;<br \/>\nimport org.slf4j.Logger;<br \/>\nimport org.slf4j.LoggerFactory;<br \/>\nLogger LOGGER = LoggerFactory.getLogger(this.getClass());<br \/>\nsql = providedscripts.BonitaSql.newInstance(&#8220;jdbc:mysql:\/\/10.11.12.13:3306\/grails&#8221;,&#8221;user&#8221;, &#8220;password&#8221;, new com.mysql.jdbc.Driver())<br \/>\nsql.eachRow(&#8220;select * from person&#8221;) { LOGGER.error(&#8220;Person = &#8221; \u00a0+ it.first_name + &#8221; &#8221; + it.last_name); }<br \/>\n[\/cc]\n<h2>Groovy web link encoding that works<\/h2>\n[cc lang=&#8221;groovy&#8221;]\n<p>def gotoLink = configMap[&#8216;wwwformspath&#8217;]+java.net.URLEncoder.encode(pdfFinalPdfWww).replaceAll(&#8220;\\\\+&#8221;, &#8216;%20&#8217;);<br \/>\nstring=&#8221;<a href=\"\\&quot;&quot;+gotoLink+&quot;\\&quot;\" target=\"\\&quot;_blank\\&quot;\" rel=\"noopener noreferrer\">Click to edit PDF Form<\/a>&#8220;;<\/p>\n[\/cc]\n","protected":false},"excerpt":{"rendered":"<p>I seem to use this code all the time so I published it for others to use. Java Date to MySQL [cc lang=&#8221;groovy&#8221;] java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;); String currentTime = sdf.format(dt); [\/cc] date MySQL string to Java: [cc lang=&#8221;groovy&#8221;] import java.text.SimpleDateFormat; import java.text.DateFormat; String target = &#8220;2012-02-01 20:29:30&#8221;; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-bentley-autoplant"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Really common groovy and Java code for Bonita - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Really common groovy and Java code for Bonita - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"I seem to use this code all the time so I published it for others to use. Java Date to MySQL [cc lang=&#8221;groovy&#8221;] java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;); String currentTime = sdf.format(dt); [\/cc] date MySQL string to Java: [cc lang=&#8221;groovy&#8221;] import java.text.SimpleDateFormat; import java.text.DateFormat; String target = &#8220;2012-02-01 20:29:30&#8221;; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-23T06:12:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:25:06+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Really common groovy and Java code for Bonita\",\"datePublished\":\"2013-01-23T06:12:23+00:00\",\"dateModified\":\"2022-02-03T17:25:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/\"},\"wordCount\":228,\"articleSection\":[\"B-AutoPLANT\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/\",\"name\":\"Really common groovy and Java code for Bonita - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2013-01-23T06:12:23+00:00\",\"dateModified\":\"2022-02-03T17:25:06+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/really-common-groovy-and-java-code-for-bonita\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Really common groovy and Java code for Bonita\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Really common groovy and Java code for Bonita - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/","og_locale":"en_US","og_type":"article","og_title":"Really common groovy and Java code for Bonita - ELB Solutions.com Inc.","og_description":"I seem to use this code all the time so I published it for others to use. Java Date to MySQL [cc lang=&#8221;groovy&#8221;] java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(&#8220;yyyy-MM-dd HH:mm:ss&#8221;); String currentTime = sdf.format(dt); [\/cc] date MySQL string to Java: [cc lang=&#8221;groovy&#8221;] import java.text.SimpleDateFormat; import java.text.DateFormat; String target = &#8220;2012-02-01 20:29:30&#8221;; [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2013-01-23T06:12:23+00:00","article_modified_time":"2022-02-03T17:25:06+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Really common groovy and Java code for Bonita","datePublished":"2013-01-23T06:12:23+00:00","dateModified":"2022-02-03T17:25:06+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/"},"wordCount":228,"articleSection":["B-AutoPLANT"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/","url":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/","name":"Really common groovy and Java code for Bonita - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2013-01-23T06:12:23+00:00","dateModified":"2022-02-03T17:25:06+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/really-common-groovy-and-java-code-for-bonita\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Really common groovy and Java code for Bonita"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":5,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":2885,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/80\/revisions\/2885"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}