Really common groovy and Java code for Bonita

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]

What the blog is about

This is a blog of sorts to discuss what types of interesting things one can do with technology. It is a resume of sorts, but it is also meant to inspire others that really interesting things can be done with the right tools. For each major type of platform, there will be a separate blog created. The intent is to explore and expose some items that can help the readers of this blog. You are not alone – and it can be done.

My major platforms that I will blog are

  • pure web tools and integration (php, javascript, mySQL),
  • Bonita BPM development (Bonita, Java, groovy, mySQL),
  • Filemaker integration (oh the things that can be done),
  • ZOHO development (online office suite) and
  • .net development
  • macros and scripting (Excel, Applescript, mouse control, scheduling etc.)
  • other platforms like integration into Facebook etc.

I will also have a shameless blog about the projects that we have worked on – a resume of sorts but more geared to let people know the depth and intensity if they are interested in knowing various aspects of my resume. If you want to see my resume, see it on linked-in.