PreviousNext…

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.

Comments

  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.

About

I’m a developer / general IT wrangler, specialising in web apps, the mobile web, enterprise Java and the odd Domino system.

Best described as a simpleton, but kindly. Read more…