Writes a JavaScript script tag that shows a date and time in the user's locale.  Prints <code>&amp;#160;</code>
if the date is <code>-1</code>.
Writes to the internal <code>PrintWriter</code>.

@deprecated
@see #writeDateTimeJavaScript(long)
559208
@Deprecated
	public ChainWriter printDateTimeJS(long date, Sequence sequence, Appendable scriptOut) throws IOException {
		return writeDateTimeJavaScript(date==-1 ? null : new Date(date), sequence, scriptOut);
	}
793592
function log(msg) {
  var d = new Date(), ts;
  ts = d.toLocaleTimeString().split(' ');
  ts = ts[0] + '.' + d.getMilliseconds() + ' ' + ts[1];
  
  console.log('[' + ts + '] ' + msg);
}
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;
    }
1324124
public void printDate(WriteStreamOld os)
    throws IOException
  {
    os.print(DAY_NAMES[(int) (_dayOfEpoch % 7 + 11) % 7]);
    os.write(',');
    os.write(' ');
    os.print((_dayOfMonth + 1) / 10);
    os.print((_dayOfMonth + 1) % 10);
    os.write(' ');
    os.print(MONTH_NAMES[(int) _month]);
    os.write(' ');
    os.print(_year);
    os.write(' ');
    os.print((_timeOfDay / 36000000) % 10);
    os.print((_timeOfDay / 3600000) % 10);
    os.write(':');
    os.print((_timeOfDay / 600000) % 6);
    os.print((_timeOfDay / 60000) % 10);
    os.write(':');
    os.print((_timeOfDay / 10000) % 6);
    os.print((_timeOfDay / 1000) % 10);

    if (_zoneName == null) {
      os.print(" GMT");
      return;
    }

    long offset = _zoneOffset;

    if (offset < 0) {
      os.write(' ');
      os.write('-');
      offset = - offset;
    } else {
      os.write(' ');
      os.write('+');
    }

    os.print((offset / 36000000) % 10);
    os.print((offset / 3600000) % 10);
    os.print((offset / 600000) % 6);
    os.print((offset / 60000) % 10);

    os.write(' ');
    os.write('(');
    os.print(_zoneName);
    os.write(')');
  }
1246388
private static String formatUTCDateAsLocalDateTime(Date javaDate) {
    // Now back from start of day in UTC to LocalDateTime to express that we don't know the
    // timezone.
    LocalDateTime localDateTime = javaDate.toInstant().atZone(UTC).toLocalDateTime();
    // And format to string
    return localDateTime.toString();
  }
889734
@Nonnull
    @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
    public String format(@Nonnull Date date) {
        SimpleDateFormat dateFormat = dateFormats.poll();
        if (dateFormat == null) {
            dateFormat = new SimpleDateFormat(pattern, locale);
            dateFormat.setTimeZone(timeZone);
        }
        try {
            return dateFormat.format(date);
        } finally {
            dateFormats.offer(dateFormat);
        }
    }
1339990
function buildISOLocalDate (date) {
	var out;
	if (date.year !== undefined) {
		out = date.year;
	}
	if (date.month !== undefined) {
		out += '-' + pad(date.month + 1);
	}
	if (date.day !== undefined) {
		out += '-' + pad(date.day);
	}
	if (date.hour !== undefined) {
		out += 'T' + pad(date.hour);
	}
	if (date.minute !== undefined) {
		out += ':' + pad(date.minute);
	}
	if (date.second !== undefined) {
		out += ':' + pad(date.second);
	}
	return out;

	function pad(number) {
		if (number < 10) {
			return '0' + number;
		}
		return number;
	}

}
421375
public static final String printFinishDateTime(Date value)
   {
      if (value != null)
      {
         value = DateHelper.addDays(value, 1);
      }
      return (value == null ? null : DATE_FORMAT.get().format(value));
   }
224058
public void setTime(Date time)
    {
        String timeString = "";
        if (time != null)
    		timeString = timeFormat.format(time);
        jTextField3.setText(timeString);
        jTimeButton1.setTargetDate(time);
    }
295111
public void xmlWriteOn(FormattedWriter writer) throws IOException 
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd @ HH:mm:ss.SSS");
        String timeNow = dateFormat.format(new Date());
        writer.newLine(); 
        writer.startTag(XML_EXPIRER);
        writer.indent();
        writer.newLine();
        writer.taggedValue("timeNow", timeNow);
        writer.newLine();
        writer.taggedValue("interval", interval);
        writer.newLine();
        writer.taggedValue("addEnabled", Boolean.valueOf(addEnabled));
        writer.newLine();
        writer.taggedValue("runEnabled", Boolean.valueOf(runEnabled));
        writer.newLine();
        writer.taggedValue("cleanupFlag", Boolean.valueOf(cleanupDeletedItems));
        writer.newLine();
        writer.taggedValue("expirerStartTime", dateFormat.format(new Date(expirerStartTime)));
        writer.newLine();
        writer.taggedValue("expirerStopTime", dateFormat.format(new Date(expirerStopTime)));
        writer.newLine();
        writer.taggedValue("nextLogIndex", diagIndex);
        writer.newLine();

        for (int i = 0; i < MAX_DIAG_LOG; i++)
        {
            String str =
            "Cycle="
            + i
            + (diagIndex == i ? ":*" : ": ")
            + dateFormat.format(new Date(alarmTime[i]))
            + " size="
            + logIndexSize[i]
            + " processed="
            + logProcessed[i]
            + " expired="
            + logExpired[i]
            + " remain="
            + logRemain[i]
            + " gone="
            + logGone[i]
            + " cleaned="
            + logCleaned[i];
            writer.taggedValue("info", str);
            writer.newLine();
        }

        writer.startTag(XML_STORED_EXCEPTION);
        if (lastException == null)
        {
            writer.write("No exceptions recorded");
        }
        else
        {
            writer.indent();
            writer.newLine();
            writer.taggedValue("time", new Date(lastExceptionTime));
            writer.outdent();
            writer.write(lastException);
            writer.newLine();
        }
        writer.endTag(XML_STORED_EXCEPTION);

        writer.outdent();
        writer.newLine();
        writer.endTag(XML_EXPIRER);
    }
606718
@Override
    public int print(
        ChronoDisplay formattable,
        Appendable buffer,
        AttributeQuery attributes,
        Set<ElementPosition> positions,
        boolean quickPath
    ) throws IOException {

        if (!formattable.hasTimezone()) {
            throw new IllegalArgumentException(
                "Cannot extract timezone name from: " + formattable);
        }

        TZID tzid = formattable.getTimezone();

        if (tzid instanceof ZonalOffset) {
            return this.fallback.print(formattable, buffer, attributes, positions, quickPath);
        }

        String name;

        if (formattable instanceof UnixTime) {
            Timezone zone = Timezone.of(tzid);
            UnixTime ut = UnixTime.class.cast(formattable);

            name =
                zone.getDisplayName(
                    this.getStyle(zone.isDaylightSaving(ut)),
                    quickPath
                        ? this.locale
                        : attributes.get(Attributes.LANGUAGE, Locale.ROOT));
        } else {
            throw new IllegalArgumentException(
                "Cannot extract timezone name from: " + formattable);
        }

        int start = -1;
        int printed;

        if (buffer instanceof CharSequence) {
            start = ((CharSequence) buffer).length();
        }

        buffer.append(name);
        printed = name.length();

        if (
            (start != -1)
            && (printed > 0)
            && (positions != null)
        ) {
            positions.add(
                new ElementPosition(
                    TimezoneElement.TIMEZONE_ID,
                    start,
                    start + printed));
        }

        return printed;

    }
187758
@Override
  public void write(JsonWriterImpl out, ZonedDateTime value)
  {
    out.write(value.format(_formatter));
  }
671956
private void writeObject(ObjectOutputStream out) throws IOException {
        ObjectOutputStream.PutField fields = out.putFields();
        fields.put("language", baseLocale.getLanguage());
        fields.put("script", baseLocale.getScript());
        fields.put("country", baseLocale.getRegion());
        fields.put("variant", baseLocale.getVariant());
        fields.put("extensions", localeExtensions == null ? "" : localeExtensions.getID());
        fields.put("hashcode", -1); // place holder just for backward support
        out.writeFields();
    }
812808
public static String write(Date value) {
		if (value==null) return null;
		String text = ThreadLocalDateFormatter.format(value, FULL);
		return text;
	}
395467
function tlid__toDate(str) {
  // var dt = new Date(str); //@s 181223 Wont work as it require "-"
  var tlidValue = tlid__xtr(str);
  var r = "";

  var y = "20" + getchk_sub(tlidValue, 0, 2); // will bug in 82 years, well, I am not pessimistic here but possibly will not be there or if I do, I wont care so much... I must add a reminder for 2099/12/31 to update tlid.todate.... ;)

  var m = getchk_sub(tlidValue, 2, 4) - 1;
  var d = getchk_sub(tlidValue, 4, 6);

  r = `${y}/${m != "" ? m : 1}/${d != "" ? d : 1}`;

  if (debugDt) console.log(`Year: ${y}`);
  if (debugDt) console.log(`Month: ${m}`);
  if (debugDt) console.log(`Day: ${d}`);
  var h = "00";
  var M = "00";
  var s = "00";
  var ms = "000";

  try {

    h = getchk_sub(tlidValue, 6, 8);
    if (debugDt) console.log(`Hour: ${h}`);




    M = getchk_sub(tlidValue, 8, 10);
    if (debugDt) console.log(`Minutes: ${M}`);



    s = getchk_sub(tlidValue, 10, 12);
    if (debugDt) console.log(`Seconds: ${s}`);



    ms = getchk_sub(tlidValue, 12, 13);
    ms = getchk_sub(tlidValue, 12, 14);
    ms = getchk_sub(tlidValue, 12, 15);
    ms = getchk_sub(tlidValue, 12, 16);

    if (debugDt) console.log(`MiliSeconds: ${ms}`);


  } catch (error) {

  }
  if (debugDt) console.log("R: " + r);

  var dt = new Date(r);

  if (y != "")
    if (m != "")
      if (d != "")
        if (h != "")
          if (M != "")
            if (s != "")
              if (ms != "")
                dt = new Date(Date.UTC(y, m, d, h, M, s, ms));
              else
                dt = new Date(Date.UTC(y, m, d, h, M, s));
            else
              dt = new Date(Date.UTC(y, m, d, h, M));
          else
            dt = new Date(Date.UTC(y, m, d, h));
        else
          dt = new Date(Date.UTC(y, m, d));
      else
        dt = new Date(Date.UTC(y, m));
    else
      dt = new Date(Date.UTC(y));

  if (debugDt) console.log("TZ: " + dt.getTimezoneOffset());

  return dt;
}
534630
public String printShortLocaleTime()
  {
    _date.setTime(_localTimeOfEpoch);

    if (_shortTimeFormat == null)
      _shortTimeFormat = DateFormat.getTimeInstance(DateFormat.SHORT);

    return _shortTimeFormat.format(_date);
  }
464952
@Override
    public final int doEndTag() throws JspException {
	String date_formatted = default_text;

	if (output_date != null) {
	    // Get the pattern to use
	    SimpleDateFormat sdf;
	    String pat = pattern;

	    if (pat == null && patternid != null) {
		Object attr = pageContext.findAttribute(patternid);
		if (attr != null) pat = attr.toString();
	    }

	    if (pat == null) {
		sdf = new SimpleDateFormat();
		pat = sdf.toPattern();
	    }

	    // Get a DateFormatSymbols
	    if (symbolsRef != null) {
		symbols = (DateFormatSymbols) pageContext.findAttribute(symbolsRef);
		if (symbols == null) {
		    throw new JspException("datetime format tag could not find dateFormatSymbols for symbolsRef \"" + symbolsRef + "\".");
		}
	    }

	    // Get a SimpleDateFormat using locale if necessary
	    if (localeRef != null) {
		Locale locale = (Locale) pageContext.findAttribute(localeRef);
		if (locale == null) {
		    throw new JspException("datetime format tag could not find locale for localeRef \"" + localeRef + "\".");
		}

		sdf = new SimpleDateFormat(pat, locale);
	    }
	    else if (locale_flag) {
		sdf = new SimpleDateFormat(pat, pageContext.getRequest().getLocale());
	    }
	    else if (symbols != null) {
		sdf = new SimpleDateFormat(pat, symbols);
	    }
	    else {
		sdf = new SimpleDateFormat(pat);
	    }

	    // See if there is a timeZone
	    if (timeZone_string != null) {
		TimeZone timeZone = (TimeZone) pageContext.getAttribute(timeZone_string, PageContext.SESSION_SCOPE);
		if (timeZone == null) {
		    throw new JspTagException("Datetime format tag timeZone " + "script variable \"" + timeZone_string + " \" does not exist");
		}
		sdf.setTimeZone(timeZone);
	    }

	    // Format the date for display
	    date_formatted = sdf.format(output_date);
	}

	try {
	    pageContext.getOut().write(date_formatted);
	}
	catch (Exception e) {
	    throw new JspException("IO Error: " + e.getMessage());
	}

	return EVAL_PAGE;
    }