Skip to content

Tag: parsing

Parsing prices with Currency Symbol in Java

I want to parse a String that i have into a Number. This is the Code that i’m using but not working: This results in a java.text.ParseException So i want to match the String into a number, i don’t really care about the currency, but it would be nice to have. I want the following kind of Strings ma…

How to abbreviate HTML with Java?

A user enters text as HTML in a form, for example: I want to be able to output only a part of the string ( for example the first 20 characters ) without breaking the HTML structure of the user’s input. In this case: which renders as Is there a Java library able to do this, or a simple method

How can I scan a maven repository?

I’m developing a code-sharing plugin for eclipse (for a bachelor thesis project). Currently I’m trying to scan a maven repository and generate a package list. I can download and parse a pom.xml using the maven.model classes, but I can’t figure out which maven classes are responsible for pars…

Convert Month String to Integer in Java

Given a month string such as: Is there any core Java or third party library functionality that would allow you to convert this string to the corresponding month number in a locale agnostic way? Answer An alternative to SimpleDateFormat using Joda time:

Remove HTML tags from a String

Is there a good way to remove HTML from a Java string? A simple regex like will work, but some things like & won’t be converted correctly and non-HTML between the two angle brackets will be removed (i.e. the .*? in the regex will disappear). Answer Use a HTML parser instead of regex. This is dea…