All posts in 'Java'

Some random Grails thoughts and tipps

04-Dec-08

Lately i’ve been rambling and ranting a lot on twitter about the Grails framework. To my surprise, many other developers actually read this tweets and helped me out on some problems. Thanks a lot gals and guys, i really appreciate that. Me rambling isn’t meant to be personal at any time, i guess you know […]

Read the complete article »

RFC3339 revisited

13-Nov-08

Not just for ruby but also the corresponding formats for Java public static final SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat("yyyy-MM-dd’T’HH:mm:ssZ");public static final SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat("yyyy-MM-dd’T’HH:mm:ssZ"); and for Oracle SELECT to_timestamp_tz(’1979-21-09T06:54:00+01:00′,’YYYY-MM-DD"T"HH24:MI:SSTZH:TZM’) FROM dual /select to_timestamp_tz(‘1979-21-09T06:54:00+01:00′,’YYYY-MM-DD"T"HH24:MI:SSTZH:TZM’) from dual / Oracle

Read the complete article »

Enabling tooltips on a JTree

12-Aug-08

Thinks i keep forgetting. Today: Enabling a JTree in J2SE to show different tooltips on his nodes: 1. Create a custom tree renderer like so: import java.awt.Component;   import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer;   public class TooltipTreeRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int […]

Read the complete article »

regex: URL thingy with username, password, host and port

07-Jul-08

Just in case i do keep forgetting that stuff, here’s a regex for decoding urls like ftp://user:somepass@somehost:someport in Java: final Hashtable<String, Integer> portMap = new Hashtable<String, Integer>(); portMap.put("ftp", 21); portMap.put("sftp", 22);   final Pattern urlPattern = Pattern.compile("(ftp|sftp)://(\\S+):(\\S+)@([\\S&&[^:]]+)(:(\\d+))?");   final Matcher m = urlPattern.matcher(url); if(!m.matches()) throw new RuntimeException("Invalid ftp url!");   final String protocol = m.group(1).toLowerCase(); […]

Read the complete article »