Tag: Java
-
How To Generate XSD from XML / Convert XML to XSD
I had to complete a project that involved working with a web service. Problem was, I had the XML files, but needed the XML Schema Definition (XSD) schemas, and coming up with them manually would have been too tedious and would have took too much time. So I went online, and found 2 reliable methods. […]
-
Formatting a Decimal Number to 2 Decimal Places in Java or JSP
I was looking around for the class to format a number to 2 decimal places while I was coding Java, or specifically JSP, and I found it. First, you need to import the DecimalFormat class, so have this line at the top of your Java file: import java.text.DecimalFormat; Or if you’re running JSP: And here’s […]
-
Replace/remove character in a String
To replace all occurences of a given character : String.replaceAll(“n”, “”); // Remove all n String.replaceAll(“n”, “r”); // Replace n by r To replace a character at a specified position : public static String replaceCharAt(String s, int pos, char c) { return s.substring(0,pos) + c + s.substring(pos+1); } To remove a character : public static […]