Using GregorianCalendar with SimpleDateFormat

SimpleDateFormat.format() method takes a Date as a parameter. You can get a Date from a Calendar by calling its getTime() method: public static String format(GregorianCalendar calendar) { SimpleDateFormat fmt = new SimpleDateFormat(“dd-MMM-yyyy”); fmt.setCalendar(calendar); String dateFormatted = fmt.format(calendar.getTime()); return dateFormatted; } Also note that the months start at 0, so you probably meant: int month = … Read more

java.lang.IllegalArgumentException: Invalid in servlet mapping

<url-pattern>*NEXTEVENT*</url-pattern> The URL pattern is not valid. It can either end in an asterisk or start with one (to denote a file extension mapping). The url-pattern specification: A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping. A string beginning with a ‘*.’ prefix is used as … Read more

Illegal remote method in java

All of the methods on a RMI Remote interface must declare RemoteException in their throws clause, e.g.: public String getId() throws RemoteException; It’s not clear why the exception names getId() specifically, it’s probably just the first method it checked. Also, the getLeafNodes() and getNeighborhoodList() methods should have return types that specify Node, not NodeImpl, otherwise … Read more

Google In-App billing, IllegalArgumentException: Service Intent must be explicit, after upgrading to Android L Dev Preview

I had the same problem and explicitly setting the package solved it. Similar to Aleksey’s answer, but simpler: Intent intent = new Intent(“com.android.vending.billing.InAppBillingService.BIND”); // This is the key line that fixed everything for me intent.setPackage(“com.android.vending”); getContext().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);

Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error

While Bruce’s answer does solve the problem, it does it in a very brutal way which harms the UX, as it will clear the focus of every view once we did a scroll. It deals with the symptom of the problem but it does not solve the actual cause. how to reproduce the problem: Your … Read more

Android 5.0 (L) Service Intent must be explicit in Google analytics

If you’re trying to use Google’s Licensing mechanism, solution that worked for me: // explicit Intent, safe Intent serviceIntent = new Intent(ILicensingService.class.getName()); serviceIntent.setPackage(“com.android.vending”); boolean bindResult = mContext.bindService(serviceIntent, this, Context.BIND_AUTO_CREATE); This is located in com/google/android/vending/licensing/LicenseChecker.java. Do a search for “Base64.decode(“ Edit: Adding reference to Google Licensing java file that has to be patched: com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150) patch: new … Read more

java.lang.IllegalArgumentException: Removing a detached instance com.test.User#5

EntityManager#remove() works only on entities which are managed in the current transaction/context. In your case, you’re retrieving the entity in an earlier transaction, storing it in the HTTP session and then attempting to remove it in a different transaction/context. This just won’t work. You need to check if the entity is managed by EntityManager#contains() and … Read more

tech