Part an SMPTE formatted timecode (<code>[-][dd:]hh:mm:ss:ff</code> -or <code>[-][dd:]hh:mm:ss;ff</code> for drop-frame
timecode
alongside a timebase

@param smpte
@param timebase

@return
354441
@Deprecated
	public static final Timecode getSmpteTimecode(final String smpte, final Timebase timebase)
	{
		return getInstance(smpte, timebase);
	}
1151360
public static String elasticSearchTimeFormatToISO8601(String time) {
        try {
            DateTime dt = DateTime.parse(time, ES_DATE_FORMAT_FORMATTER);
            return getISO8601String(dt);
        } catch (IllegalArgumentException e) {
            return time;
        }
    }
669756
public static final StringBuilder appendDate(StringBuilder sb, Long millis) {
        if (millis == null)
            return sb.append((Long) null);
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(millis);
        TimeZone zone = cal.getTimeZone();
        sb.append(cal.get(Calendar.YEAR)).append('/');
        int m = cal.get(Calendar.MONTH);
        m++; // Month range is 0 - 11. Bump one for formatting
        if (m < 10)
            sb.append('0');
        sb.append(m).append('/');
        int d = cal.get(Calendar.DAY_OF_MONTH);
        if (d < 10)
            sb.append('0');
        sb.append(d).append('-');
        int h = cal.get(Calendar.HOUR_OF_DAY);
        if (h < 10)
            sb.append('0');
        sb.append(h).append(':');
        m = cal.get(Calendar.MINUTE);
        if (m < 10)
            sb.append('0');
        sb.append(m).append(':');
        int s = cal.get(Calendar.SECOND);
        if (s < 10)
            sb.append('0');
        sb.append(s).append('.');
        int ms = cal.get(Calendar.MILLISECOND);
        if (ms < 100)
            sb.append('0');
        if (ms < 10)
            sb.append('0');
        sb.append(ms).append('-');
        sb.append(zone.getDisplayName(zone.inDaylightTime(cal.getTime()), TimeZone.SHORT));
        sb.append('[').append(millis).append(']');
        return sb;
    }
422587
public void setTimestampProperty(String pstrSection, String pstrProp, 
                    					Timestamp ptsVal, String pstrComments)
    {
        INISection objSec   = null;

        objSec = (INISection) this.mhmapSections.get(pstrSection);
        if (objSec == null)
        {
            objSec = new INISection(pstrSection);
            this.mhmapSections.put(pstrSection, objSec);
        }
        objSec.setProperty(pstrProp, timeToStr(ptsVal, this.mstrTimeStampFmt), 
                        	pstrComments);
    }
1232022
static TimeUnit parseTimeUnit(String key, @Nullable String value) {
    requireArgument((value != null) && !value.isEmpty(), "value of key %s omitted", key);
    @SuppressWarnings("NullAway")
    char lastChar = Character.toLowerCase(value.charAt(value.length() - 1));
    switch (lastChar) {
      case 'd':
        return TimeUnit.DAYS;
      case 'h':
        return TimeUnit.HOURS;
      case 'm':
        return TimeUnit.MINUTES;
      case 's':
        return TimeUnit.SECONDS;
      default:
        throw new IllegalArgumentException(String.format(
            "key %s invalid format; was %s, must end with one of [dDhHmMsS]", key, value));
    }
  }
519643
public static final String getFormattedTime(long timeleft) {

    String formattedTime = null;

    if (timeleft <= 0)
      formattedTime = String.format("%02d:%02d:%02d", 0, 0, 0);
    else {
      final long hours = TimeUnit.MILLISECONDS.toHours(timeleft);

      final long minutes = TimeUnit.MILLISECONDS.toMinutes(timeleft
        - TimeUnit.HOURS.toMillis(hours));

      final long seconds = TimeUnit.MILLISECONDS.toSeconds(timeleft
        - TimeUnit.HOURS.toMillis(hours) - TimeUnit.MINUTES.toMillis(minutes));

      formattedTime = String.format("%02d:%02d:%02d", hours, minutes, seconds);
    }

    return formattedTime;
  }
1348428
public static Timecode valueOf(String timecode) throws IllegalArgumentException
    {
        Timecode tc = new Timecode();
        return (Timecode) tc.parse(timecode);
    }
1361360
public static long timeStringAs(String str, TimeUnit unit) {
    String lower = str.toLowerCase(Locale.ROOT).trim();

    try {
      Matcher m = Pattern.compile("(-?[0-9]+)([a-z]+)?").matcher(lower);
      if (!m.matches()) {
        throw new NumberFormatException("Failed to parse time string: " + str);
      }

      long val = Long.parseLong(m.group(1));
      String suffix = m.group(2);

      // Check for invalid suffixes
      if (suffix != null && !timeSuffixes.containsKey(suffix)) {
        throw new NumberFormatException("Invalid suffix: \"" + suffix + "\"");
      }

      // If suffix is valid use that, otherwise none was provided and use the default passed
      return unit.convert(val, suffix != null ? timeSuffixes.get(suffix) : unit);
    } catch (NumberFormatException e) {
      String timeError = "Time must be specified as seconds (s), " +
              "milliseconds (ms), microseconds (us), minutes (m or min), hour (h), or day (d). " +
              "E.g. 50s, 100ms, or 250us.";

      throw new NumberFormatException(timeError + "\n" + e.getMessage());
    }
  }
16018
public static DateTime toDateTime(Locale locale, String str, TimeZone tz, DateTime defaultValue, boolean useCommomDateParserAsWell) {
	str = str.trim();
	tz = ThreadLocalPageContext.getTimeZone(tz);
	DateFormat[] df;

	// get Calendar
	Calendar c = JREDateTimeUtil.getThreadCalendar(locale, tz);

	// datetime
	ParsePosition pp = new ParsePosition(0);
	df = FormatUtil.getDateTimeFormats(locale, tz, false);// dfc[FORMATS_DATE_TIME];
	Date d;
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1)) + " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;

	    optimzeDate(c, tz, d);
	    return new DateTimeImpl(c.getTime());
	}

	// date
	df = FormatUtil.getDateFormats(locale, tz, false);
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1)) + " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
	    optimzeDate(c, tz, d);
	    return new DateTimeImpl(c.getTime());
	}

	// time
	df = FormatUtil.getTimeFormats(locale, tz, false);// dfc[FORMATS_TIME];
	for (int i = 0; i < df.length; i++) {
	    SimpleDateFormat sdf = (SimpleDateFormat) df[i];
	    // print.e(sdf.format(new Date(108,3,6,1,2,1))+ " : "+sdf.toPattern());
	    pp.setErrorIndex(-1);
	    pp.setIndex(0);
	    sdf.setTimeZone(tz);
	    d = sdf.parse(str, pp);
	    if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
	    c.setTimeZone(tz);
	    c.setTime(d);
	    c.set(Calendar.YEAR, 1899);
	    c.set(Calendar.MONTH, 11);
	    c.set(Calendar.DAY_OF_MONTH, 30);
	    c.setTimeZone(tz);
	    return new DateTimeImpl(c.getTime());
	}

	if (useCommomDateParserAsWell) return DateCaster.toDateSimple(str, CONVERTING_TYPE_NONE, true, tz, defaultValue);
	return defaultValue;
    }
1029569
public static Timestamp getTimeStamp(String time) {
	if (time.equalsIgnoreCase("now")) {
	    return Timestamp.now();
	} else {
	    int quantity = 0;
	    String unit = "";
	    Pattern lastNUnitsPattern = Pattern
		    .compile(
			    "last\\s*(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks).*",
			    Pattern.CASE_INSENSITIVE);
	    Matcher lastNUnitsMatcher = lastNUnitsPattern.matcher(time);
	    while (lastNUnitsMatcher.find()) {
		quantity = "".equals(lastNUnitsMatcher.group(1)) ? 1 : Integer
			.valueOf(lastNUnitsMatcher.group(1));
		unit = lastNUnitsMatcher.group(2).toLowerCase();
		switch (unit) {
		case "min":
		case "mins":
		    return Timestamp.now().minus(
			    TimeDuration.ofMinutes(quantity));
		case "hour":
		case "hours":
		    return Timestamp.now()
			    .minus(TimeDuration.ofHours(quantity));
		case "day":
		case "days":
		    return Timestamp.now().minus(
			    TimeDuration.ofHours(quantity * 24));
		case "week":
		case "weeks":
		    return Timestamp.now().minus(
			    TimeDuration.ofHours(quantity * 24 * 7));
		default:
		    break;
		}
	    }

	    Pattern nUnitsAgoPattern = Pattern
		    .compile(
			    "(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks)\\s*ago",
			    Pattern.CASE_INSENSITIVE);
	    Matcher nUnitsAgoMatcher = nUnitsAgoPattern.matcher(time);
	    while (nUnitsAgoMatcher.find()) {
		quantity = "".equals(nUnitsAgoMatcher.group(1)) ? 1 : Integer
			.valueOf(nUnitsAgoMatcher.group(1));
		unit = nUnitsAgoMatcher.group(2).toLowerCase();
		switch (unit) {
		case "min":
		case "mins":
		    return Timestamp.now().minus(
			    TimeDuration.ofMinutes(quantity));

		case "hour":
		case "hours":
		    return Timestamp.now()
			    .minus(TimeDuration.ofHours(quantity));
		case "day":
		case "days":
		    return Timestamp.now().minus(
			    TimeDuration.ofHours(quantity * 24));
		case "week":
		case "weeks":
		    return Timestamp.now().minus(
			    TimeDuration.ofHours(quantity * 24 * 7));
		default:
		    break;
		}
	    }
	    TimestampFormat format = new TimestampFormat(
		    "yyyy-MM-dd'T'HH:mm:ss");
	    try {
		return format.parse(time);
	    } catch (ParseException e) {
		return null;
	    }
	}
    }
399406
public int setTime(java.util.Date time, boolean bDisplayOption, int iMoveMode)
    {
        java.util.Date m_DateTime = (java.util.Date)m_data;
        int iYear = DBConstants.FIRST_YEAR;
        int iMonth = DBConstants.FIRST_DAY;
        int iDate = DBConstants.FIRST_MONTH;
        if (m_DateTime != null) //|| (m_CurrentLength == 0))
        {
            m_calendar.setTime(m_DateTime);
            iYear = m_calendar.get(Calendar.YEAR);
            iMonth = m_calendar.get(Calendar.MONTH);
            iDate = m_calendar.get(Calendar.DATE);
        }
        m_calendar.setTime(time);
        int iHour = m_calendar.get(Calendar.HOUR_OF_DAY);
        int iMinute = m_calendar.get(Calendar.MINUTE);
        int iSecond = m_calendar.get(Calendar.SECOND);
        m_calendar.set(iYear, iMonth, iDate, iHour, iMinute, iSecond);
        java.util.Date dateNew = m_calendar.getTime();
        return this.setDateTime(dateNew, bDisplayOption, iMoveMode);
    }
777917
public TimecodeBuilder withTimecode(Timecode timecode)
	{
		return this
				       .withNegative(timecode.isNegative())
				       .withDays(timecode.getDaysPart())
				       .withHours(timecode.getHoursPart())
				       .withMinutes(timecode.getMinutesPart())
				       .withSeconds(timecode.getSecondsPart())
				       .withFrames(timecode.getFramesPart())
				       .withDropFrame(timecode.isDropFrame())
				       .withRate(timecode.getTimebase());
	}
103125
static DateFormat getBasicDateFormatter() {
        String pattern;
        int patternLength;
        int endOfSecsIndex;
        // Retrieve a standard Java DateFormat object with desired format.
        DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
        if (formatter instanceof SimpleDateFormat) {
            // Retrieve the pattern from the formatter, since we will need to modify it.
            SimpleDateFormat sdFormatter = (SimpleDateFormat) formatter;
            pattern = sdFormatter.toPattern();
            // Append milliseconds and timezone after seconds
            patternLength = pattern.length();
            endOfSecsIndex = pattern.lastIndexOf('s') + 1;
            String newPattern = pattern.substring(0, endOfSecsIndex) + ":SSS z";
            if (endOfSecsIndex < patternLength)
                newPattern += pattern.substring(endOfSecsIndex, patternLength);
            // 0-23 hour clock (get rid of any other clock formats and am/pm)
            newPattern = newPattern.replace('h', 'H');
            newPattern = newPattern.replace('K', 'H');
            newPattern = newPattern.replace('k', 'H');
            newPattern = newPattern.replace('a', ' ');
            newPattern = newPattern.trim();
            sdFormatter.applyPattern(newPattern);
            formatter = sdFormatter;
        } else {
            formatter = new SimpleDateFormat("yy.MM.dd HH:mm:ss:SSS z");
        }
        // PK13288 Start
        if (sysTimeZone != null) {
            formatter.setTimeZone(sysTimeZone);
        }
        // PK13288 End.
        return formatter;
    }
625368
public static final String formatTime(long timestamp) {
        DateFormat sdf = dateformats.get();
        if (sdf == null) {
            sdf = getDateFormat();
            dateformats.set(sdf);
        }
        return sdf.format(timestamp);
    }
928921
public static CharSequence getRelativeTimeSpanString(Context context, ReadableInstant time) {
        int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_YEAR | FORMAT_ABBREV_MONTH;
        return getRelativeTimeSpanString(context, time, flags);
    }
357250
public static DateTimeFormatter timeFormatterWithOptionalMilliseconds() {
        // This is the .SSS part
        DateTimeParser ms = new DateTimeFormatterBuilder()
                .appendLiteral(".")
                .appendFractionOfSecond(1, 3)
                .toParser();

        return new DateTimeFormatterBuilder()
                .append(DateTimeFormat.forPattern(ES_DATE_FORMAT_NO_MS).withZoneUTC())
                .appendOptional(ms)
                .toFormatter();
    }
696429
protected byte[] getTimeStampToken(byte[] imprint) throws Exception {
        byte[] respBytes = null;
        try {
            // Setup the time stamp request
            TimeStampRequestGenerator tsqGenerator = new TimeStampRequestGenerator();
            tsqGenerator.setCertReq(true);
            // tsqGenerator.setReqPolicy("1.3.6.1.4.1.601.10.3.1");
            BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
            TimeStampRequest request = tsqGenerator.generate(X509ObjectIdentifiers.id_SHA1 , imprint, nonce);
            byte[] requestBytes = request.getEncoded();
            
            // Call the communications layer
            respBytes = getTSAResponse(requestBytes);
            
            // Handle the TSA response
            TimeStampResponse response = new TimeStampResponse(respBytes);
            
            // validate communication level attributes (RFC 3161 PKIStatus)
            response.validate(request);
            PKIFailureInfo failure = response.getFailInfo();
            int value = (failure == null) ? 0 : failure.intValue();
            if (value != 0) {
                // @todo: Translate value of 15 error codes defined by PKIFailureInfo to string
                throw new Exception("Invalid TSA '" + tsaURL + "' response, code " + value);
            }
            // @todo: validate the time stap certificate chain (if we want
            //        assure we do not sign using an invalid timestamp).
            
            // extract just the time stamp token (removes communication status info)
            TimeStampToken  tsToken = response.getTimeStampToken();
            if (tsToken == null) {
                throw new Exception("TSA '" + tsaURL + "' failed to return time stamp token: " + response.getStatusString());
            }

            byte[] encoded = tsToken.getEncoded();
            
            // Update our token size estimate for the next call (padded to be safe)
            this.tokSzEstimate = encoded.length + 32;
            return encoded;
        } catch (Exception e) {
            throw e;
        } catch (Throwable t) {
            throw new Exception("Failed to get TSA response from '" + tsaURL +"'", t);
        }
    }