Internal set of time by parsing value string.

@param value
@param format
a {@code DateFormat}, protected by the use of a ThreadLocal.
@param tz
@throws ParseException
425808
private void setTime(final String value, final DateFormat format,
			final java.util.TimeZone tz) throws ParseException {

		if (tz != null) {
			format.setTimeZone(tz);
		}
		setTime(format.parse(value).getTime());
	}
247728
public static ZonedDateTime toDateTime(Object value, EvaluationContext ctx) {
        if (value instanceof String) {
            Temporal temporal = ctx.getDateParser().auto((String) value);
            if (temporal != null) {
                return toDateTime(temporal, ctx);
            }
        }
        else if (value instanceof LocalDate) {
            return ((LocalDate) value).atStartOfDay(ctx.getTimezone());
        }
        else if (value instanceof ZonedDateTime) {
            return ((ZonedDateTime) value).withZoneSameInstant(ctx.getTimezone());
        }

        throw new EvaluationError("Can't convert '" + value + "' to a datetime");
    }
1008795
public static Date fromRfcDateTime(final String val,
                                     final TimeZone tz) throws BadDateException {
    try {
      synchronized (rfcDateTimeTZFormat) {
        rfcDateTimeTZFormat.setTimeZone(tz);
        return rfcDateTimeTZFormat.parse(val);
      }
    } catch (Throwable t) {
      throw new BadDateException();
    }
  }
327784
private void setTzFormatString(final  TimeZone tz )
    {
        int zIndex = _formatString.indexOf( "ZZZ" );
        if( zIndex >= 0 )
        {
            String ss1 = _formatString.substring( 0, zIndex );
            String ss2 = _formatString.substring( zIndex+3 );
            int tzOffset = tz.getRawOffset();
            
            StringBuffer sb = new StringBuffer(_formatString.length()+10);
            sb.append(ss1);
            sb.append("'");
            if( tzOffset >= 0 )
                sb.append( '+' );
            else
            {
                tzOffset = -tzOffset;
                sb.append( '-' );
            }
            
            int raw = tzOffset / (1000*60);		// Convert to seconds
            int hr = raw / 60;
            int min = raw % 60;
            
            if( hr < 10 )
                sb.append( '0' );
            sb.append( hr );
            if( min < 10 )
                sb.append( '0' );
            sb.append( min );
            sb.append( '\'' );
            
            sb.append(ss2);
            _tzFormatString=sb.toString();            
        }
        else
            _tzFormatString=_formatString;
        setMinFormatString();
    }
1215219
public static Date parseEpochTimestamp(String value)
   {
      Date result = null;

      if (value.length() > 0)
      {
         if (!value.equals("-1 -1"))
         {
            Calendar cal = DateHelper.popCalendar(JAVA_EPOCH);

            int index = value.indexOf(' ');
            if (index == -1)
            {
               if (value.length() < 6)
               {
                  value = "000000" + value;
                  value = value.substring(value.length() - 6);
               }

               int hours = Integer.parseInt(value.substring(0, 2));
               int minutes = Integer.parseInt(value.substring(2, 4));
               int seconds = Integer.parseInt(value.substring(4));

               cal.set(Calendar.HOUR, hours);
               cal.set(Calendar.MINUTE, minutes);
               cal.set(Calendar.SECOND, seconds);
            }
            else
            {
               long astaDays = Long.parseLong(value.substring(0, index));
               int astaSeconds = Integer.parseInt(value.substring(index + 1));

               cal.add(Calendar.DAY_OF_YEAR, (int) (astaDays - ASTA_EPOCH));
               cal.set(Calendar.MILLISECOND, 0);
               cal.set(Calendar.SECOND, 0);
               cal.set(Calendar.HOUR, 0);
               cal.add(Calendar.SECOND, astaSeconds);
            }

            result = cal.getTime();
            DateHelper.pushCalendar(cal);
         }
      }

      return result;
   }
1165276
public static Date strToTime(String time) throws ParseException {

        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd:HH");

        java.util.Date d = sdf.parse(time);

        return d;
    }
707798
public static String fromUnixtime(long unixtime, String format, TimeZone tz) {
		SimpleDateFormat formatter = FORMATTER_CACHE.get(format);
		formatter.setTimeZone(tz);
		Date date = new Date(unixtime * 1000);
		try {
			return formatter.format(date);
		} catch (Exception e) {
			LOG.error("Exception when formatting.", e);
			return null;
		}
	}
663690
public static Long toTimestampTz(String dateStr, String format, String tzStr) {
		TimeZone tz = TIMEZONE_CACHE.get(tzStr);
		return toTimestamp(dateStr, format, tz);
	}
65303
public final void setFormat(String value) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setFormat", value);
        jmo.getPayloadPart().setField(JsPayloadAccess.FORMAT, value);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setFormat");
    }
407399
public static String dateFormat(String dateStr, String fromFormat, String toFormat, TimeZone tz) {
		SimpleDateFormat fromFormatter = FORMATTER_CACHE.get(fromFormat);
		fromFormatter.setTimeZone(tz);
		SimpleDateFormat toFormatter = FORMATTER_CACHE.get(toFormat);
		toFormatter.setTimeZone(tz);
		try {
			return toFormatter.format(fromFormatter.parse(dateStr));
		} catch (ParseException e) {
			LOG.error("Exception when formatting: '" + dateStr +
				"' from: '" + fromFormat + "' to: '" + toFormat + "'", e);
			return null;
		}
	}
1078256
function( dateString, format ) {

			this.clear();
			this.setFormat(format);

			var parts = [],
				tzArray = [],
				position = 0,
				datePart = '',
				timePart = '',
				timeZonePart = '';


			// discover date time separtor for auto profile
			// Set to 'T' by default
			if(dateString.indexOf('t') > -1) {
				this.autoProfile.sep = 't';
			}
			if(dateString.indexOf('z') > -1) {
				this.autoProfile.tzZulu = 'z';
			}
			if(dateString.indexOf('Z') > -1) {
				this.autoProfile.tzZulu = 'Z';
			}
			if(dateString.toUpperCase().indexOf('T') === -1) {
				this.autoProfile.sep = ' ';
			}


			dateString = dateString.toUpperCase().replace(' ','T');

			// break on 'T' divider or space
			if(dateString.indexOf('T') > -1) {
				parts = dateString.split('T');
				datePart = parts[0];
				timePart = parts[1];

				// zulu UTC
				if(timePart.indexOf( 'Z' ) > -1) {
					this.z = true;
				}

				// timezone
				if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
					tzArray = timePart.split( 'Z' ); // incase of incorrect use of Z
					timePart = tzArray[0];
					timeZonePart = tzArray[1];

					// timezone
					if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
						position = 0;

						if(timePart.indexOf( '+' ) > -1) {
							position = timePart.indexOf( '+' );
						} else {
							position = timePart.indexOf( '-' );
						}

						timeZonePart = timePart.substring( position, timePart.length );
						timePart = timePart.substring( 0, position );
					}
				}

			} else {
				datePart = dateString;
			}

			if(datePart !== '') {
				this.parseDate( datePart );
				if(timePart !== '') {
					this.parseTime( timePart );
					if(timeZonePart !== '') {
						this.parseTimeZone( timeZonePart );
					}
				}
			}
			return this.toString( this.format );
		}
966663
public static String formatDate(final Date value, final Locale locale)
    {
        return withinLocale(new Callable<String>()
        {
            public String call() throws Exception
            {
                return formatDate(value);
            }
        }, locale);
    }
494625
private String formatTimestamp(String value) {
        try {
            long longValue = Long.parseLong(value);
            return Utils.formatDate(longValue);
        } catch (NumberFormatException e) {
            return "Invalid timestamp: " + value; 
        }
    }
1121612
public void timestamp(String name, ZonedDateTime value) {
		Counter counter = get(name, CounterType.Timestamp);
		counter.setTime(value != null ? value : ZonedDateTime.now(ZoneId.of("Z")));
		update();
	}
9213
public static Time parseTime(final String date, final String format, final TimeZone timeZone) {
        if (N.isNullOrEmpty(date) || (date.length() == 4 && "null".equalsIgnoreCase(date))) {
            return null;
        }

        return createTime(parse(date, format, timeZone));
    }
950408
public static String formatDate(final Date value, final String pattern)
    {
        return new SimpleDateFormat(pattern, currentLocale()).format(value);
    }
450267
function (format, tz) {
      // Default format is the same as toISOString
      if (!format) format = 'yyyy-MM-dd HH:mm:ss';
      var result = format;
      var tzInfo = tz ? timezoneJS.timezone.getTzInfo(this.getTime(), tz) : this.getTimezoneInfo();
      var _this = this;
      // If timezone is specified, get a clone of the current Date object and modify it
      if (tz) {
        _this = this.clone();
        _this.setTimezone(tz);
      }
      var hours = _this.getHours();
      return result
      // fix the same characters in Month names
      .replace(/a+/g, function () { return 'k'; })
      // `y`: year
      .replace(/y+/g, function (token) { return _fixWidth(_this.getFullYear(), token.length); })
      // `d`: date
      .replace(/d+/g, function (token) { return _fixWidth(_this.getDate(), token.length); })
      // `m`: minute
      .replace(/m+/g, function (token) { return _fixWidth(_this.getMinutes(), token.length); })
      // `s`: second
      .replace(/s+/g, function (token) { return _fixWidth(_this.getSeconds(), token.length); })
      // `S`: millisecond
      .replace(/S+/g, function (token) { return _fixWidth(_this.getMilliseconds(), token.length); })
      // `M`: month. Note: `MM` will be the numeric representation (e.g February is 02) but `MMM` will be text representation (e.g February is Feb)
      .replace(/M+/g, function (token) {
        var _month = _this.getMonth(),
        _len = token.length;
        if (_len > 3) {
          return timezoneJS.Months[_month];
        } else if (_len > 2) {
          return timezoneJS.Months[_month].substring(0, _len);
        }
        return _fixWidth(_month + 1, _len);
      })
      // `k`: AM/PM
      .replace(/k+/g, function () {
        if (hours >= 12) {
          if (hours > 12) {
            hours -= 12;
          }
          return 'PM';
        }
        return 'AM';
      })
      // `H`: hour
      .replace(/H+/g, function (token) { return _fixWidth(hours, token.length); })
      // `E`: day
      .replace(/E+/g, function (token) { return DAYS[_this.getDay()].substring(0, token.length); })
      // `Z`: timezone abbreviation
      .replace(/Z+/gi, function () { return tzInfo.tzAbbr; });
    }