Check if a given time lies between two times regardless of date

You can use the Calendar class in order to check. For example: try { String string1 = “20:11:13”; Date time1 = new SimpleDateFormat(“HH:mm:ss”).parse(string1); Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(time1); calendar1.add(Calendar.DATE, 1); String string2 = “14:49:00”; Date time2 = new SimpleDateFormat(“HH:mm:ss”).parse(string2); Calendar calendar2 = Calendar.getInstance(); calendar2.setTime(time2); calendar2.add(Calendar.DATE, 1); String someRandomTime = “01:00:00”; Date d = new SimpleDateFormat(“HH:mm:ss”).parse(someRandomTime); … Read more

Multipart email with text and calendar: Outlook doesn’t recognize ics

You are missing the iTIP method, both in the content-type: Content-Type: text/calendar; charset=”utf-8″; method=REQUEST and as a VCALENDAR property as well: BEGIN:VCALENDAR VERSION:2.0 METHOD:REQUEST PRODID:-//GourmetPortal//NONSGML rr//DE The method might be PUBLISH or REQUEST (in which case you also miss some ATTENDEE property). Then, some clients are ignoring iMIP in multipart/alternative and are looking only as … Read more

Calendar Recurring/Repeating Events – Best Storage Method

Storing “Simple” Repeating Patterns For my PHP/MySQL based calendar, I wanted to store repeating/recurring event information as efficiently as possibly. I didn’t want to have a large number of rows, and I wanted to easily lookup all events that would take place on a specific date. The method below is great at storing repeating information … Read more

How to tackle daylight savings using TimeZone in Java

This is the problem to start with: Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(“EST”)); The 3-letter abbreviations should be wholeheartedly avoided in favour of TZDB zone IDs. EST is Eastern Standard Time – and Standard time never observes DST; it’s not really a full time zone name. It’s the name used for part of a time zone. (Unfortunately … Read more

Programmatically add custom event in the iPhone Calendar

Based on Apple Documentation, this has changed a bit as of iOS 6.0. 1) You should request access to the user’s calendar via “requestAccessToEntityType:completion:” and execute the event handling inside of a block. 2) You need to commit your event now or pass the “commit” param to your save/remove call Everything else stays the same… … Read more

What is the most straightforward way to pad empty dates in sql results (on either mysql or perl end)?

When you need something like that on server side, you usually create a table which contains all possible dates between two points in time, and then left join this table with query results. Something like this: create procedure sp1(d1 date, d2 date) declare d datetime; create temporary table foo (d date not null); set d … Read more