Recurring Events in FullCalendar

Simple Repeating Events To add a simple alternative to those listed here, Fullcalendar now (somewhat) supports weekly recurring events. So if you only need something like: [Every Monday and Thursday from 10:00am to 02:00pm], you can use the following: events: [{ title:”My repeating event”, start: ’10:00′, // a start time (10am in this example) end: … Read more

Calculate business days

Here’s a function from the user comments on the date() function page in the PHP manual. It’s an improvement of an earlier function in the comments that adds support for leap years. Enter the starting and ending dates, along with an array of any holidays that might be in between, and it returns the working … Read more

How to sanity check a date in Java

Key is df.setLenient(false);. This is more than enough for simple cases. If you are looking for a more robust (I doubt) and/or alternate libraries like joda-time then look at the answer by the user “tardate” final static String DATE_FORMAT = “dd-MM-yyyy”; public static boolean isDateValid(String date) { try { DateFormat df = new SimpleDateFormat(DATE_FORMAT); df.setLenient(false); … Read more

How do I calculate someone’s age in Java?

JDK 8 makes this easy and elegant: public class AgeCalculator { public static int calculateAge(LocalDate birthDate, LocalDate currentDate) { if ((birthDate != null) && (currentDate != null)) { return Period.between(birthDate, currentDate).getYears(); } else { return 0; } } } A JUnit test to demonstrate its use: public class AgeCalculatorTest { @Test public void testCalculateAge_Success() { … Read more

Why is January month 0 in Java Calendar?

It’s just part of the horrendous mess which is the Java date/time API. Listing what’s wrong with it would take a very long time (and I’m sure I don’t know half of the problems). Admittedly working with dates and times is tricky, but aaargh anyway. Do yourself a favour and use Joda Time instead, or … Read more

Java Android Calendar/DateFormat this format XXXXXXXX [closed]

Here’s the modern answer and some additional thoughts. For most purposes you should not want your date formatted to 27032019. It’s not easily readable by humans and not recommended for serialization. Also consider not using Calendar, DateFormat, SimpleDateFormat or Date. Those classes are long outdated and poorly designed. Instead you may use java.time, the modern … Read more