Converts a datetime string as returned from the Ripple REST API into a java date object. The
string is the UTC time in format yyyy-MM-dd'T'hh:mm:ss.SSS'Z' e.g. 2015-06-13T11:45:20.102Z

@throws com.fasterxml.jackson.databind.exc.InvalidFormatException
502916
public static Date ToDate(final String datetime) throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    return format.parse(datetime);
  }
997702
private static DateFormat getDateFormat() {
        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("dd/MMM/yyyy HH:mm:ss:SSS z");
        }
        return formatter;
    }
276162
@Override
    public Date parseRFC2109Time(String input) throws ParseException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "rfc2109 parsing [" + input + "]");
        }
        Date d = attemptParse(getFormat().get2109Parse(), input);
        if (null == d) {
            throw new ParseException("Unparseable [" + input + "]", 0);
        }
        return d;
    }
839815
public static String convertDateToDateString(Date date) {
		if (date == null) {
			return null;
		} else {
			// DateFormat df = new SimpleDateFormat("yyyy-MM-dd'Z'");
			DateTimeFormatter df = FORMATTER_DATE_Z;
			return df.print(date.getTime());
		}
	}
516584
private static Date getDateOrNull(JSONObject obj, String field)
			throws JSONException {
		String dateStr = JsonInput.getStringOrNull(obj, field);
		if (dateStr == null)
			return null;
		try {
			if (dateStr.length() >= 5 && dateStr.charAt(4) == '/') {
				return RedmineDateUtils.FULL_DATE_FORMAT.get().parse(dateStr);
			}
			if (dateStr.endsWith("Z")) {
				dateStr = dateStr.substring(0, dateStr.length() - 1)
						+ "GMT-00:00";
			} else {
				final int inset = 6;
				if (dateStr.length() <= inset)
					throw new JSONException("Bad date value " + dateStr);
				String s0 = dateStr.substring(0, dateStr.length() - inset);
				String s1 = dateStr.substring(dateStr.length() - inset,
						dateStr.length());
				dateStr = s0 + "GMT" + s1;
			}
			return RedmineDateUtils.FULL_DATE_FORMAT_V2.get().parse(dateStr);
		} catch (ParseException e) {
			throw new JSONException("Bad date value " + dateStr);
		}
	}
367564
def __deserialize_datetime(self, string):
        
        try:
            from dateutil.parser import parse
            timestr = str(datetime.fromtimestamp(string/1000))
            return parse(timestr)
        except ImportError:
            return string
        except ValueError:
            raise ApiException(
                status=0,
                reason=(
                    "Failed to parse `{0}` into a datetime object"
                    .format(string)
                )
            )
104826
public static String getDateTimeStr(Date d) {
        if (d == null)
            return "";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
        // 20140315 test will problem +0000
        return sdf.format(d);
    }
1225262
static public long getDateTime(String s, String format, TimeZone tz)
    {
        long ret = 0L;
        SimpleDateFormat df = null;

        try
        {
            if(s != null && s.length() > 0)
            {
                df = formatPool.getFormat(format);
                df.setTimeZone(tz);
                Date dt = df.parse(s);
                ret = dt.getTime();
            }
        }
        catch(Exception e)
        {
        }

        if(df != null)
            formatPool.release(df);

        return ret;
    }
977107
public synchronized static String convertToAgmipDateString(Date date) {
        if (date != null) {
            return dateFormatter.format(date);
        } else {
            return null;
        }
    }
1340455
def string_to_date(value):
    
    if isinstance(value, datetime.date):
        return value

    return dateutil.parser.parse(value).date()
203629
def _convert_date_time_string(dt_string):
    '''
    
    '''
    dt_string = dt_string.split('.')[0]
    dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S')
    return dt_obj.strftime('%Y-%m-%d %H:%M:%S')
265281
def format_date(cls, timestamp):
        
        if not timestamp:
            raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))

        return timestamp.strftime(cls.DATE_FORMAT)
1164068
private String convertDate(String date) {
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
        try {
            Date creationDate = sdf.parse(date);
            sdf = new SimpleDateFormat("\\'yr'yyyy\\'mo'MM\\'dy'dd\\'hr'HH\\'min'mm\\'sec'ss");
            return sdf.format(creationDate);
        } catch(ParseException pe) {
            pe.printStackTrace();
            return "";
        }
    }
439487
public Date parse(String dateString)
	throws ParseException
	{
		Date result = null;
		ParseException lastException = null;
		
		for (DateFormat format : inputFormats)
		{
			try
			{
				result = ((DateFormat) format.clone()).parse(dateString);	// DateFormat is not thread safe.
				lastException = null;
				break;
			}
			catch (ParseException e)
			{
				// Keep the first exception that occurred.
				if (lastException == null)
				{
					lastException = e;
				}
				// And just try the next input format.
			}
		}

		if (lastException != null)
		{
			throw lastException;
		}

		return result;
	}
679407
public static String format( TimeZone timeZone, Date date ) {
        return format( DateFormat.DATE_FORMAT_STR_ISO8601, timeZone, date );
    }
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;
   }
486059
public static String format( DateTimeFormat format, TimeZone timeZone, Date date ) {
        return format.format( date, timeZone );
    }