Visualization of calendar events. Algorithm to layout events with maximum width

Think of an unlimited grid with just a left edge. Each event is one cell wide, and the height and vertical position is fixed based on starting and ending times. Try to place each event in a column as far left as possible, without it intersecting any earlier event in that column. Then, when each … Read more

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

Date object to Calendar [Java]

What you could do is creating an instance of a GregorianCalendar and then set the Date as a start time: Date date; Calendar myCal = new GregorianCalendar(); myCal.setTime(date); However, another approach is to not use Date at all. You could use an approach like this: private Calendar startTime; private long duration; private long startNanos; //Nano-second … Read more

How to save and retrieve Date in SharedPreferences

To save and load accurate date, you could use the long (number) representation of a Date object. Example: //getting the current time in milliseconds, and creating a Date object from it: Date date = new Date(System.currentTimeMillis()); //or simply new Date(); //converting it back to a milliseconds representation: long millis = date.getTime(); You can use this … Read more

What parameters are required to create an “Add to Google Calendar” link?

Explanation about the available parameters: anchor address: http://www.google.com/calendar/event? This is the base of the address before the parameters below. action: action=TEMPLATE A default required parameter. src: Example: src=default%40gmail.com Format: src=text This is not covered by Google help but is an optional parameter in order to add an event to a shared calendar rather than a … Read more

Getting last day of the month in a given string date

Java 8 and above. By using convertedDate.getMonth().length(convertedDate.isLeapYear()) where convertedDate is an instance of LocalDate. String date = “1/13/2012”; LocalDate convertedDate = LocalDate.parse(date, DateTimeFormatter.ofPattern(“M/d/yyyy”)); convertedDate = convertedDate.withDayOfMonth( convertedDate.getMonth().length(convertedDate.isLeapYear())); Java 7 and below. By using getActualMaximum method of java.util.Calendar: String date = “1/13/2012”; SimpleDateFormat dateFormat = new SimpleDateFormat(“MM/dd/yyyy”); Date convertedDate = dateFormat.parse(date); Calendar c = Calendar.getInstance(); c.setTime(convertedDate); … Read more

Google Calendar Push Notifications SetUp

Create a notification channel for every individual resource, then any modification to that resource you will be then notified. Information below is directly from Google (Creating notification channels). Making watch requests: Each watchable Google Calendar API resource has an associated watch method at a URI of the following form: https://www.googleapis.com/**apiName**/**apiVersion**/**resourcePath**/watch To set up a notification … Read more

Is there any ready-made calendar control for iPhone apps? [closed]

Yes. These are the option I am aware of: EDIT: as of May 6, 2010 1) GCCalendar 2) http://github.com/klazuka/Kal 3) http://code.google.com/p/iphonecal (needs to be customized – easily – to change text from chinese to english) 4) Commercial: http://nrg.com.bd/blog/archives/36 but the look & feel of the previous ones is much, much better and they are free, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)