Feb 25

You can use the setScale() method to control the rounding of a decimal value as shown in the following example:

double value = 123.456789;
BigDecimal bd = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println(bd);

written by objects \\ tags: , , ,

Feb 20

When using Javamail to send mail the Message-ID gets set when the message is actually sent. If you want to provide your own Message-ID then you need to subclass MimeMessage. You can then use that subclass to create your message.

public class CustomMimeMessage extends MimeMessage {

	public CustomMimeMessage(Session session) {
		super(session);
	}

	@Override
	protected void updateMessageID() throws MessagingException {
		setHeader("Message-ID", "objects-message-id");
	}	
}

written by objects \\ tags: , ,

Feb 12

The following two locats are checked by Maven for its settings.xml:

  • $M2_HOME/conf/settings.xml
  • ${user.home}/.m2/settings.xml

The settings defined in the users home directory take presedence over the corresponding global settings.

written by objects \\ tags: , ,