Value that must match the given timestamp format
@param format timestamp format
@param example example date and time to use for generated bodies
326591
public static PactDslJsonRootValue timestamp(String format, Date example) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    PactDslJsonRootValue value = new PactDslJsonRootValue();
    value.setValue(instance.format(example));
    value.setMatcher(value.matchTimestamp(format));
    return value;
  }
606992
public LambdaDslJsonArray timestamp(final String format, final Date example) {
        pactArray.timestamp(format, example);
        return this;
    }
1009533
public static String format(Date date, String format) {
		if (null == date || StrUtil.isBlank(format)) {
			return null;
		}
		return format(date, FastDateFormat.getInstance(format));
	}
1110153
public static String formatDate(java.util.Date pDate, String format) {

        if (pDate == null) {
            pDate = new java.util.Date();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(pDate);
    }
927841
public static int getFormatDepth(SampleFormat format) {
		switch (format) {
			case U8:
			case U8P:
				return 1;
			case S16:
			case S16P:
				return 2;
			case S32:
			case S32P:
				return 4;
			case FLT:
			case FLTP:
				return 4;
			case DBL:
			case DBLP:
				return 8;

			default:
				return 0;
		}
	}
427141
private String formatDateTime(Object value)
   {
      String result = null;
      if (value instanceof Date)
      {
         result = m_formats.getDateTimeFormat().format(value);
      }
      return result;
   }
284686
public static String getDateString(String format, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
519060
public static Sample ofTimeText(long time, String textValue) {
        return new Sample(time, null, null, textValue);
    }
693078
public PactDslJsonArray timestamp(String format) {
      FastDateFormat instance = FastDateFormat.getInstance(format);
      body.put(instance.format(new Date(DATE_2000)));
      generators.addGenerator(Category.BODY, rootPath + appendArrayIndex(0), new DateTimeGenerator(format));
      matchers.addRule(rootPath + appendArrayIndex(0), matchTimestamp(format));
      return this;
    }
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;
		}
	}
1276993
public static PactDslRootValue time(String format) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    PactDslRootValue value = new PactDslRootValue();
    value.generators.addGenerator(Category.BODY, "", new TimeGenerator(format));
    value.setValue(instance.format(new Date(DATE_2000)));
    value.setMatcher(value.matchTime(format));
    return value;
  }
2889
public void selectExample(final ExampleData example) {
		try {
			StringBuilder exampleName = new StringBuilder();
			if (example.getExampleGroupName() != null && !example.getExampleGroupName().equals("")) {
				exampleName.append(example.getExampleGroupName()).append(" - ");
			}
			exampleName.append(example.getExampleName());
			selectExample(example.getExampleClass().newInstance(), exampleName.toString());
		} catch (Exception e) {
			WMessages.getInstance(this).error("Error selecting example \"" + example.
					getExampleName() + '"');
			selectExample(new ErrorComponent(e.getMessage(), e), "Error");
		}
	}
1332186
public LambdaDslObject timestamp(String name, String format) {
        object.timestamp(name, format);
        return this;
    }
1182259
public Date getDate(String name, String format) {
        Object value = get(name);
        if (value instanceof Date) {
            return (Date)value;
        }
        
        if (value != null) {
            try {
                return new SimpleDateFormat(format).parse(value.toString());
            } catch (ParseException e) {
                // ignore
            }
        }
        return null;
    }
1206132
public String format(long timestamp) {

        // If the format is unknown, use the default formatter.
        if (invalidFormat) {
            return formatter.format(timestamp);
        }

        try {
            long delta = timestamp - refTimestamp;

            // If we need to reformat
            if (delta >= pdiff || delta < ndiff) {
                StringBuffer refTime = new StringBuffer();
                refTimestamp = timestamp;
                formatter.format(timestamp, refTime, position);

                refMilli = Long.parseLong(refTime.substring(position.getBeginIndex(), position.getEndIndex()));

                refBeginning = refTime.substring(0, position.getBeginIndex());
                refEnding = refTime.substring(position.getEndIndex());

                pdiff = 1000 - refMilli;
                ndiff = -refMilli;
                return refTime.toString();
            } else {
                StringBuffer sb = new StringBuffer();
                long newMilli = delta + refMilli;
                if (newMilli >= 100)
                    sb.append(refBeginning).append(newMilli).append(refEnding);
                else if (newMilli >= 10)
                    sb.append(refBeginning).append('0').append(newMilli).append(refEnding);
                else
                    sb.append(refBeginning).append("00").append(newMilli).append(refEnding);
                return sb.toString();

            }
        } catch (Exception e) {
            // Throw FFDC in case anything goes wrong
            // Still generate the date via the SimpleDateFormat
            invalidFormat = true;
            return formatter.format(timestamp);
        }
    }
1158877
@UserFunction( "apoc.temporal.formatDuration" )
    @Description( "apoc.temporal.formatDuration(input, format) | Format a Duration" )
    public String formatDuration(
            @Name("input") Object input,
            @Name("format") String format
    ) {
        try {
            LocalDateTime midnight = LocalDateTime.of(0, 1, 1, 0, 0, 0, 0);
            LocalDateTime newDuration = midnight.plus( (DurationValue) input );

            DateTimeFormatter formatter = getOrCreate(format);

            return newDuration.format(formatter);
        } catch (Exception e){
        throw new RuntimeException("Available formats are:\n" +
                String.join("\n", getTypes()) +
                "\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats " +
                "and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
        }
    }
848235
private void validateTimestampProtocol(String protocolString, String timestampFormat, String shape2) {
        if (!StringUtils.isNullOrEmpty(timestampFormat) && isNonJsonProtocol(protocolString)) {
            throw new IllegalArgumentException(String.format(
                "Shape %s has timestamp format provided. Timestamp format for requests is not supported for xml, query or ec2 "
                + "protocol",
                shape2));

        }
    }