Returns the milli second part of the datetime.
352399
private static int getMillis(String dateStr) {
		int length = dateStr.length();
		if (length == 19) {
			// "1999-12-31 12:34:56", no milli second left
			return 0;
		} else if (length == 21) {
			// "1999-12-31 12:34:56.7", return 7
			return Integer.parseInt(dateStr.substring(20)) * 100;
		} else if (length == 22) {
			// "1999-12-31 12:34:56.78", return 78
			return Integer.parseInt(dateStr.substring(20)) * 10;
		} else if (length >= 23 && length <= 26) {
			// "1999-12-31 12:34:56.123" ~ "1999-12-31 12:34:56.123456"
			return Integer.parseInt(dateStr.substring(20, 23)) * 10;
		} else {
			return 0;
		}
	}
1172232
def millis_interval(start, end):
    """"""
    diff = end - start
    millis = diff.days * 24 * 60 * 60 * 1000
    millis += diff.seconds * 1000
    millis += diff.microseconds / 1000
    return millis
894760
def seconds2time(s):
    """"""
    hour, temp = divmod(s, 3600)
    minute, temp = divmod(temp, 60)
    temp, second = math.modf(temp)
    return datetime.time(hour=int(hour), minute=int(minute), second=int(second),
                         microsecond=int(round(temp * 1e6)))
1369444
public static String datetime(long millis) {
		if (sFormat == null) {
			sFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"),
					US);
		}
		return sFormat.format(millis);
	}
1191268
def as_datetime(self):
        '''
        '''
        year = int(self.year)
        month = int(self.month) if self.month else 1
        day = int(self.day) if self.day else 1
        hour = int(self.hour) if self.hour else 0
        minute = int(self.minute) if self.minute else 0
        second = int(self.second) if self.second else 0
        microsecond = int(self.microsecond) if self.microsecond else 0
        return datetime.datetime(year, month, day, hour, minute, second, microsecond)
1374342
public static Expression dateDiffMillis(String expression1, String expression2, DatePart part) {
        return dateDiffMillis(x(expression1), x(expression2), part);
    }
1339784
def datetime(self):
        """"""
        if not self._datetime_calculated:
            self._datetime_calculated = True

            # if no datetime after 10 tokens, break to avoid parsing
            # very long lines
            split_tokens = self.split_tokens[:10]

            for offs in range(len(split_tokens)):
                dt = self._match_datetime_pattern(split_tokens[offs:offs + 4])
                if dt:
                    self._datetime = dt
                    self._datetime_nextpos = offs
                    if self._datetime_format.startswith("iso8601"):
                        self._datetime_nextpos += 1
                    else:
                        self._datetime_nextpos += 4

                    # separate datetime str and linestr
                    self._line_str = (' '.join(self.split_tokens
                                               [self._datetime_nextpos:]))

                    if self.level:
                        self._datetime_nextpos += 2

                    self._reformat_timestamp(self._datetime_format)
                    break

        return self._datetime
305189
public static long millis(final String time, final String timeUnit) {
      return TIMEUNITS.get(timeUnit).toMillis(Long.parseLong(time));
   }
185316
public static long convertToUtc(long millis, String tz)
    {
        long ret = millis;
        if(tz != null && tz.length() > 0)
        {
            DateTime dt = new DateTime(millis, DateTimeZone.forID(tz));
            ret = dt.withZoneRetainFields(DateTimeZone.forID("UTC")).getMillis();
        }
        return ret;
    }
464321
private MillisProvider getCurrentTimeMillisProvider() {
		try {
			Field providerField = DateTimeUtils.class.getDeclaredField("cMillisProvider");
			providerField.setAccessible(true);
			return (MillisProvider) providerField.get(null);
		} catch (NoSuchFieldException e) {
			throw new UnsupportedClassVersionError("The JodaTime version in use is not supported by TimeMachine. Try to use version 2.2");
		} catch (IllegalArgumentException e) {
			throw new RuntimeException("This should not happen", e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException("This should not happen", e);
		}
	}
973473
def get_decimal_time(self):
        '''
        
        '''
        return decimal_time(self.data['year'],
                            self.data['month'],
                            self.data['day'],
                            self.data['hour'],
                            self.data['minute'],
                            self.data['second'])
373546
public static String formatDuration(long millis) {
		StringBuilder sb = new StringBuilder();
		if(millis > DAY_MILLIS) {
			sb.append(millis / DAY_MILLIS);
			sb.append(" days, ");
			millis %= DAY_MILLIS;
		}
		if(millis > HOUR_MILLIS) {
			sb.append(millis / HOUR_MILLIS);
			sb.append(" hours, ");
			millis %= HOUR_MILLIS;
		}
		if(millis > MINUTE_MILLIS) {
			sb.append(millis / MINUTE_MILLIS);
			sb.append(" minutes, ");
			millis %= MINUTE_MILLIS;
		}
		if(millis > SECOND_MILLIS) {
			sb.append(millis / SECOND_MILLIS);
			sb.append(" seconds, ");
			millis %= SECOND_MILLIS;
		}
		sb.append(millis);
		sb.append(" milliseconds");
		return sb.toString();
	}
208973
private static DateTime readOffset(boolean isPlus, TimeZone timeZone, DateTime dt, int years, int months, int days, int hours, int minutes, int seconds, int milliSeconds,
	    DateString ds, boolean checkAfterLast, DateTime defaultValue) {
	// timeZone=ThreadLocalPageContext.getTimeZone(timeZone);
	if (timeZone == null) return defaultValue;
	// HOUR
	int hourLength = ds.getPos();
	int hour = ds.readDigits();
	hourLength = ds.getPos() - hourLength;
	if (hour == -1) return defaultValue;

	// MINUTE
	int minute = 0;
	if (!ds.isAfterLast()) {
	    if (!(ds.fwIfCurrent(':') || ds.fwIfCurrent('.'))) return defaultValue;
	    minute = ds.readDigits();
	    if (minute == -1) return defaultValue;

	}
	else if (hourLength > 2) {
	    int h = hour / 100;
	    minute = hour - (h * 100);
	    hour = h;
	}

	if (minute > 59) return defaultValue;
	if (hour > 14 || (hour == 14 && minute > 0)) return defaultValue;

	long offset = hour * 60L * 60L * 1000L;
	offset += minute * 60 * 1000;

	if (!checkAfterLast || ds.isAfterLast()) {
	    long time = util.toTime(TimeZoneConstants.UTC, years, months, days, hours, minutes, seconds, milliSeconds, 0);

	    if (isPlus) time -= offset;
	    else time += offset;
	    return new DateTimeImpl(time, false);
	}
	return defaultValue;
    }
38124
def _date2int(date):
        
        if isinstance(date, str):
            if date.endswith(' 00:00:00') or date.endswith('T00:00:00'):
                # Ignore time suffix.
                date = date[0:-9]
            tmp = datetime.datetime.strptime(date, '%Y-%m-%d')
            return tmp.toordinal()

        if isinstance(date, datetime.date):
            return date.toordinal()

        if isinstance(date, int):
            return date

        raise ValueError('Unexpected type {0!s}'.format(date.__class__))
1322582
public static int secondsDiff(Date earlierDate, Date laterDate) {
        if (earlierDate == null || laterDate == null) {
            return 0;
        }

        return (int) ((laterDate.getTime() / SECOND_MILLIS) - (earlierDate.getTime() / SECOND_MILLIS));
    }
489584
private static long daysBetween(Date date1, Date date2) {
        long diff;
        if (date2.after(date1)) {
            diff = date2.getTime() - date1.getTime();
        } else {
            diff = date1.getTime() - date2.getTime();
        }
        return diff / (24 * 60 * 60 * 1000);
    }
392408
private static String getDuration(long millis) {
        long tsec = millis / 1000;
        long h = tsec / 60 / 60;
        long m = (tsec - h * 60 * 60) / 60;
        long s = tsec - h * 60 * 60 - m * 60;
        StringBuffer out = new StringBuffer();
        if (h > 0) {
            out.append(h + " hour");
            if (h > 1) {
                out.append('s');
            }
        }
        if (m > 0) {
            if (h > 0) {
                out.append(", ");
            }
            out.append(m + " minute");
            if (m > 1) {
                out.append('s');
            }
        }
        if (s > 0 || h == 0 && m == 0) {
            if (h > 0 || m > 0) {
                out.append(", ");
            }
            out.append(s + " second");
            if (s != 1) {
                out.append('s');
            }
        }
        return out.toString();
    }