convertStringToDate

Date sutil.convertStringToDate ( String dateString, String format ) (professional and enterprise editions only)

Description

Converts a String to a Date object using the given format. If null is given as a format, "MM/dd/yyyy HH:mm:ss.SS zzz" is used

Parameters

  • dateString The date string
  • format The format of the date, following SimpleDateFormat formatting.

Return Values

The Date object matching the date given in the String, or null if it couldn't be parsed with the given format

Change Log

Version Description
5.5.26a Available in all editions.

Examples

// Convert an input value to a date for later use
Date lastUpdate = sutil.convertStringToDate(session.getVariable("LAST_RUN_DATE"), "yyyy-MM-dd");

if(lastUpdate == null)
{
  session.logError("No last run specified, stopping scrape");
  session.stopScraping();
}