Converting a Date object to a calendar object [duplicate]

Here’s your method: public static Calendar toCalendar(Date date){ Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; } Everything else you are doing is both wrong and unnecessary. BTW, Java Naming conventions suggest that method names start with a lower case letter, so it should be: dateToCalendar or toCalendar (as shown). OK, let’s milk your code, shall … Read more

Best explanation for languages without null

I think the succinct summary of why null is undesirable is that meaningless states should not be representable. Suppose I’m modeling a door. It can be in one of three states: open, shut but unlocked, and shut and locked. Now I could model it along the lines of class Door private bool isShut private bool … Read more

Eclipse / Android : “Errors running builder ‘Android Pre Compiler’ on project…”

For those of you who don’t want to install preview version of ADT, there is a workaround described here. Open properties of project in Eclipse then Resources -> Resource filters. Click the “Add…” button -> Check “Exclude all”, “Files and folders”, “All children”. In the text entry box input “.svn” (without quotes). Restart Eclipse. I … Read more

NullPointerException stack trace not available without debug agent

With the JVM flag -XX:-OmitStackTraceInFastThrow you can disable the performance optimization of the JVM for this use case. IF this parameter is given, which disables the flag, the stacktrace will be available. For more information please have a look at the following release notes: “The compiler in the server VM now provides correct stack backtraces … Read more