.NET: Get all Outlook calendar items

I’ve studied the docs and this is my result: I’ve put a time limit of one month hard-coded, but this is just an example. public void GetAllCalendarItems() { Microsoft.Office.Interop.Outlook.Application oApp = null; Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; oApp = new Microsoft.Office.Interop.Outlook.Application(); mapiNamespace = oApp.GetNamespace(“MAPI”); ; CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); … Read more

How to convert time to ” time ago ” in android

I see mainly three ways: a) built-in options using SimpleDateFormat and DateUtils SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss.SSS’Z'”); sdf.setTimeZone(TimeZone.getTimeZone(“GMT”)); try { long time = sdf.parse(“2016-01-24T16:00:00.000Z”).getTime(); long now = System.currentTimeMillis(); CharSequence ago = DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS); } catch (ParseException e) { e.printStackTrace(); } b) external library ocpsoft/PrettyTime (based on java.util.Date) Here you have to use SimpleDateFormat, too, … 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

How can I determine the week number of a certain date?

You must use Calendar.GetDayOfWeek and Calendar.GetWeekOfYear in preference to writing yourself. You can guarantee that if you write any date / time handling code yourself it will contain faults and won’t work in different locales. public class Row { public string MonthWeek { get; set; } public string Year { get; set; } public string … Read more

How to get national holidays of selected country

Problem solved by using Google Calendar API V3. The idea I found from this post. The holiday can get from default holiday calendar of google. The ID list of default holiday calendar can be found here, support to 40 country. A piece of code that handle permission and get holiday list:- com.google.api.services.calendar.Calendar client = null; … Read more

Android – how to set an alarm to a specific date

package your.pack.name; import java.util.Calendar; import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class AlarmActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(System.currentTimeMillis()); cal.clear(); cal.set(2012,2,8,18,16); AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, … Read more

Get first next Monday after certain date?

Java 8+ LocalDate ld = LocalDate.of(2014, Month.JUNE, 12); System.out.println(ld); ld = ld.with(TemporalAdjusters.next(DayOfWeek.MONDAY)); System.out.println(ld); Which prints… 2014-06-12 2014-06-16 Because it’s possible that the date my actually be a Monday, you could also use… ld = ld.with(TemporalAdjusters.nextOrSame(DayOfWeek.MONDAY)); Java <= 7 You should be using the ThreeTen Backport, which gives you the support of the Java 8 Date/Time … Read more

Get Weeks In Month Through Javascript

Weeks start on Sunday This ought to work even when February doesn’t start on Sunday. function weekCount(year, month_number) { // month_number is in the range 1..12 var firstOfMonth = new Date(year, month_number-1, 1); var lastOfMonth = new Date(year, month_number, 0); var used = firstOfMonth.getDay() + lastOfMonth.getDate(); return Math.ceil( used / 7); } Weeks start on … Read more

A good date converter for Jalali Calendar in Java? [closed]

For better localization and language support, it is often convenient to use the ICU (International Components for Unicode) library from IBM. The APIs are similar to the standard Java APIs, but add additional support for localization and internationalization (e.g. time and calendar issues, sorting, formatting rules and a regex implementation with proper Unicode support). To … Read more