Here you can find the source of totalDays(Object o)
public static int totalDays(Object o)
//License from project: Apache License import org.joda.time.DateTime; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; public class Main{ public static final String MM_DD_YYYY = "MM/dd/yyyy"; private static final long MILLIS_OF_DAY = 24 * 60 * 60 * 1000; public static int totalDays(Object o) { DateTime dateTime = narrowDateTime(o); if (dateTime == null) { return 0; }/*from w ww . ja v a 2 s. c o m*/ long millis = dateTime.getMillis(); return (int) ((millis - millis % MILLIS_OF_DAY) / MILLIS_OF_DAY); } public static DateTime narrowDateTime(Object o) { if (o instanceof DateTime) { return (DateTime) o; } if (o instanceof Calendar) { return new DateTime(((Calendar) o).getTimeInMillis()); } if (o instanceof String) { return parse((String) o); } if (o instanceof Date) { return new DateTime(((Date) o).getTime()); } return null; } public static DateTime parse(String s) { if (Strings.isEmpty(s)) { return null; } try { SimpleDateFormat mDateFormat = new SimpleDateFormat(MM_DD_YYYY, Locale.getDefault()); mDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return new DateTime(mDateFormat.parse(s)); } catch (Exception e) { e.printStackTrace(); } return null; } }