Jul 27

You can use the getDisplayName() in the Calendar class to get a localized (according to Locale) string for any of the Calendar fields.

For example to get the day name you can use the following:

Calendar cal = Calendar.getInstance();
String day = cal.getDisplayName(Calendar.DAY_OF_WEEK, 
   Calendar.LONG, Locale.getDefault())

If you’re looking for an algorithm to get the day of the week then try Zeller’s congruence.

written by objects \\ tags: , ,

Jul 18

Check the system property “sun.arch.data.model”

System.out.println(System.getProperty("sun.arch.data.model"));

written by objects \\ tags: , , , ,

Jul 15

The Math.log() method calculates natural logarithms. If you need to use base 2 then take the natural log and divide it by ln(2)

double log2 = Math.log(x) / Math.log(2);

written by objects \\ tags: , , ,