Java dates ’n’ Strings: oh noes

Today’s Java WTF: parsing a two-digit year value from a time-date value expressed as a String. Meh, that’s not brittle or anything…

String tmp = someDoc.getItemValueString("someDateField");
String arrTmp[] = tmp.split("/");
int year = Integer.parseInt(arrTmp[2]);

That which is seen in one’s IDE cannot be unseen. Don’t do this at home kids.


  1. oh dear lordmark myers#
  2. An example of being paid by the milestone rather than by the hour. ;-) Jerry Carter#

Comments on this post are now closed.


I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.