I seem to use this code all the time so I published it for others to use.
Java Date to MySQL
[cc lang=”groovy”]
java.util.Date dt = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
String currentTime = sdf.format(dt);
[/cc]
date MySQL string to Java:
[cc lang=”groovy”]
import java.text.SimpleDateFormat;
import java.text.DateFormat;
String target = “2012-02-01 20:29:30”;
DateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”, Locale.ENGLISH);
Date result = df.parse(target);
println result;
[/cc]
Debugging to the Bonita Log
[cc lang=”groovy”]
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger LOGGER = LoggerFactory.getLogger(this.getClass());
LOGGER.error(“Your String Here”);
[/cc]
Groovy SQL in place of MySQL connector which is more of a hassle than a help
[cc lang=”groovy”]
import groovy.sql.Sql import java.sql.Connection;
import java.sql.DriverManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger LOGGER = LoggerFactory.getLogger(this.getClass());
sql = providedscripts.BonitaSql.newInstance(“jdbc:mysql://10.11.12.13:3306/grails”,”user”, “password”, new com.mysql.jdbc.Driver())
sql.eachRow(“select * from person”) { LOGGER.error(“Person = ” + it.first_name + ” ” + it.last_name); }
[/cc]
Groovy web link encoding that works
[cc lang=”groovy”]
def gotoLink = configMap[‘wwwformspath’]+java.net.URLEncoder.encode(pdfFinalPdfWww).replaceAll(“\\+”, ‘%20’);
string=”Click to edit PDF Form“;
[/cc]