May 01

The HTML parser used by HTMLEditorKit will throw a ChangedCharSetException every time a charset tag is parsed. To spo this behaviour you need set the IgnoreCharsetDirective property on the document to true.

document.putProperty("IgnoreCharsetDirective", new Boolean(true));

written by objects \\ tags: , ,

Nov 23

You can tell the parseInt() method what base number system is used by the String that is being parsed.


String hex = "a9b0";
int n = Integer.parseInt(hex, 16);

written by objects \\ tags: , ,

Oct 01

Use the parse() method of the SimpleDateFormat class. You can use setLenient(false) to force strict parsing.


DateFormat dateFormat =
   new SimpleDateFormat("hh:mm dd/MM/yy");
dateFormat.setLenient(false);
Date d = dateFormat.parse("06:23 01/05/06"); 

written by objects \\ tags: , , , ,