Posts in 2017

  • JEE Container Managed Transaction

    Monday, December 25, 2017 in Java

    Transaction Attribute Client’s Transaction Business Method’s Transaction Required None T2 T1 T1 RequiresNew None T2 T1 T2 Mandatory None error T1 T1 NotSupported None None T1 None Supports None None T1 T1 Never None None T1 Error Container Manager …

    Read more

  • Java Time Difference

    Sunday, December 24, 2017 in Java

    Time difference can be calculated by subtracting the milliseconds. And then milliseconds can be converted into different Units using TimeUnit. e.g. TimeUnit.MILLISECONDS.toSeconds(1000) will give 1 because 1 second equivalent to 1000 millisecons. …

    Read more

  • JAXRS Rest Client

    Wednesday, December 20, 2017 in Java

    Option 1 : Using interface proxy import; import; import; import; import; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import …

    Read more

  • Java get hostname and IP address

    Tuesday, December 19, 2017 in Java

    Use to get hostname or IP Address To get local hostname or IP import; public class LocalIPGetter { public static void main(String[] args) throws Exception { InetAddress inetAddress = …

    Read more

  • Avoid NullPointerException on Primitive Wrapper Objects

    Wednesday, February 22, 2017 in Java

    Using the primitive wrapper objects like Boolean, Integer or Long in operators may throw NullPointerException, if the value is null, because the primitive wrapper objects auto unboxed to primitive values when you use java operators like …

    Read more

Posts in 2016

  • Java random integer in min and max range

    Friday, March 04, 2016 in Java

    Following sample code returns a random integer within the give min and max range (both inclusive) import java.util.Random; public class RandomRange { // Declare as class variable so that it is not re-seeded every call private static Random random = …

    Read more