Encode a java date/time into a 16-bit encoded DOS time

@param javaDateTime
@return long
169713
public static int encodeTime(long javaDateTime) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(javaDateTime);
        return 2048 * cal.get(Calendar.HOUR_OF_DAY) + 32 * cal.get(Calendar.MINUTE) +
                cal.get(Calendar.SECOND) / 2;
    }
97248
def CopyToDateTimeString(self):
    
    if (self._timestamp is None or self._timestamp < self._INT64_MIN or
        self._timestamp > self._INT64_MAX):
      return None

    return super(JavaTime, self).CopyToDateTimeString()
1167032
def _encode_datetime(name, value, dummy0, dummy1):
    """"""
    if value.utcoffset() is not None:
        value = value - value.utcoffset()
    millis = int(calendar.timegm(value.timetuple()) * 1000 +
                 value.microsecond / 1000)
    return b"\x09" + name + _PACK_LONG(millis)
558210
public String getDate(long time) {

        return CmsDateUtil.getDate(new Date(time), DateFormat.SHORT, m_locale);
    }
431282
public static Date getDateFromLong(long date)
   {
      TimeZone tz = TimeZone.getDefault();
      return (new Date(date - tz.getRawOffset()));
   }
1161778
public static java.util.Date toDate(String dateTime) {
		// dateTime must have one space between the date and time...
		String date = dateTime.substring(0, dateTime.indexOf(" "));
		String time = dateTime.substring(dateTime.indexOf(" ") + 1);

		return toDate(date, time);
	}
859076
private long toLong(byte[] data)
    {
        if (data == null || data.length != 8)
            return 0x0;
        // ----------
        return (long) (
        // (Below) convert to longs before shift because digits
        // are lost with ints beyond the 32-bit limit
        (long) (0xff & data[0]) << 56 | (long) (0xff & data[1]) << 48 | (long) (0xff & data[2]) << 40
                | (long) (0xff & data[3]) << 32 | (long) (0xff & data[4]) << 24 | (long) (0xff & data[5]) << 16
                | (long) (0xff & data[6]) << 8 | (long) (0xff & data[7]) << 0);
    }
1103938
public static long getDayStartTime(final long time) {
        final Calendar start = Calendar.getInstance();
        start.setTimeInMillis(time);
        final int year = start.get(Calendar.YEAR);
        final int month = start.get(Calendar.MONTH);
        final int day = start.get(Calendar.DATE);
        start.set(year, month, day, 0, 0, 0);
        start.set(Calendar.MILLISECOND, 0);

        return start.getTimeInMillis();
    }
1065130
public static LocalDate toLocalDate(Date time)
	{
		return time.toInstant().atZone(ZoneId.systemDefault())
		.toLocalDate();
	}
104189
public static String toTimeString(long time, boolean millis) {
		GregorianCalendar cal = new GregorianCalendar(0, 0, 0);
		cal.setTimeInMillis(time);
		return toTimeString(cal, millis);
	}
1327968
public DateTime toDateTime(T dateTime) {
    try {
      @SuppressWarnings("unchecked") // Expected class.
      D dateObj = (D) PropertyUtils.getProperty(dateTime, "date");
      String timeZoneId =
          PropertyUtils.isReadable(dateTime, "timeZoneId")
              ? (String) PropertyUtils.getProperty(dateTime, "timeZoneId")
              : (String) PropertyUtils.getProperty(dateTime, "timeZoneID");
      return new DateTime(
          (Integer) PropertyUtils.getProperty(dateObj, "year"),
          (Integer) PropertyUtils.getProperty(dateObj, "month"),
          (Integer) PropertyUtils.getProperty(dateObj, "day"),
          (Integer) PropertyUtils.getProperty(dateTime, "hour"),
          (Integer) PropertyUtils.getProperty(dateTime, "minute"),
          (Integer) PropertyUtils.getProperty(dateTime, "second"),
          0,
          DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)));
    } catch (IllegalAccessException e) {
      throw new IllegalStateException("Could not access class.", e);
    } catch (InvocationTargetException e) {
      throw new IllegalStateException("Could not get field.", e);
    } catch (NoSuchMethodException e) {
      throw new IllegalStateException("Could not get field.", e);
    }
  }
721285
public static long reverseBits(final long value) {
    final long b0 = JBBPUtils.reverseBitsInByte((byte) value) & 0xFFL;
    final long b1 = JBBPUtils.reverseBitsInByte((byte) (value >> 8)) & 0xFFL;
    final long b2 = JBBPUtils.reverseBitsInByte((byte) (value >> 16)) & 0xFFL;
    final long b3 = JBBPUtils.reverseBitsInByte((byte) (value >> 24)) & 0xFFL;
    final long b4 = JBBPUtils.reverseBitsInByte((byte) (value >> 32)) & 0xFFL;
    final long b5 = JBBPUtils.reverseBitsInByte((byte) (value >> 40)) & 0xFFL;
    final long b6 = JBBPUtils.reverseBitsInByte((byte) (value >> 48)) & 0xFFL;
    final long b7 = JBBPUtils.reverseBitsInByte((byte) (value >> 56)) & 0xFFL;

    return (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
  }
180641
static public String getLongFormattedDays(long dt)
    {
        StringBuffer ret = new StringBuffer();

        long days = dt/86400000L;
        long millis = dt-(days*86400000L);
        if(days > 0)
        {
            ret.append(Long.toString(days));
            ret.append(" day");
            if(days > 1)
                ret.append("s");
        }

        long hours = millis/3600000L;
        millis = millis-(hours*3600000L);

        if(hours > 0)
        {
            if(ret.length() > 0)
                ret.append(" ");
            ret.append(Long.toString(hours));
            ret.append(" hour");
            if(hours > 1)
                ret.append("s");
        }

        long minutes = millis/60000L;
        millis = millis-(minutes*60000L);

        if(minutes > 0)
        {
            if(ret.length() > 0)
                ret.append(" ");
            ret.append(Long.toString(minutes));
            ret.append(" minute");
            if(minutes > 1)
                ret.append("s");
        }

        long seconds = millis/1000L;
        if(seconds > 0)
        {
            if(ret.length() > 0)
                ret.append(" ");
            ret.append(Long.toString(seconds));
            ret.append(" second");
            if(seconds > 1)
                ret.append("s");
        }

        return ret.toString();
    }
1169263
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(this.ciphers != null ? this.ciphers.length : 0, dst, dstIndex);
        dstIndex += 2;

        if ( this.ciphers != null ) {
            for ( int cipher : this.ciphers ) {
                SMBUtil.writeInt2(cipher, dst, dstIndex);
                dstIndex += 2;
            }
        }
        return dstIndex - start;
    }
848729
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        System.arraycopy(this.bytes, this.off, dst, dstIndex, this.len);
        return this.len;
    }
433561
public static String getShortDateString(long time, String format) {
        if (format == null || format.isEmpty()) {
            format = "yyyy-MM-dd";
        }

        SimpleDateFormat smpf = new SimpleDateFormat(format);
        return smpf.format(new Date(time));
    }
18018
def fromJD(jd, utcoffset):
        
        if not isinstance(utcoffset, Time):
            utcoffset = Time(utcoffset)
        localJD = jd + utcoffset.value / 24.0
        date = Date(round(localJD))
        time = Time((localJD + 0.5 - date.jdn) * 24)
        return Datetime(date, time, utcoffset)