jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Eckhart <>
Subject BeanShell PreProcessor Help: Date Conversion
Date Tue, 23 Mar 2010 17:10:26 GMT
I need to convert a date which I've captured in mm/dd/yyyy format into m/d/yyyy. In other words,
I need to strip any leading zeroes from the month and date displayed on one screen for verification
in a PDF.

Here's what I have in my BeanShell Preprocessor:

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;

// This line is just for debugging.
vars.put("IReadThisDate", vars.get("DepositDate"));

// Make a new Date object. It will be initialized to the
// DepositDate read in mm/dd/yyyy format.
Date OriginalDepositDate = format.parse(vars.get("DepositDate"));

// Make a SimpleDateFormat for toString()'s output. This has
// numeric month, a slash, numeric date, a slash, and a long
// year.
// Both month and date have any leading zero stripped out.
SimpleDateFormat format = new SimpleDateFormat("m/d/yyyy");

// Output to the CheckDate variable
vars.put("CheckDate", now.toString());

When I run my script with a Debug Sampler following the preprocessor, I have the variable
IReadThisDate with the same value as DepositDate. However, CheckDate is not displayed in the
Debug Sampler at all.


Any idea what's going wrong? Thanks,

Steve Eckhart
Business Analyst/Project Manager

WAUSAU Financial Systems
14010 FNB PKWY STE500
Omaha, NE 68154-5206
Main: (402) 431-8810
Direct line: (402) 715-9382
Cellular: (402) 510-5387

Enterprise Payment Solutions.
CONFIDENTIALITY NOTICE:  This electronic transmission (including files attached hereto) is
intended only for the use of the individual or entity named above.  If the reader of this
message is not the intended recipient, you are hereby notified that any disclosure, dissemination,
copying, distribution or taking of any action in reliance on the contents of this confidential
information is strictly prohibited.  If you have received this communication in error, please
destroy it and immediately notify us by return email.  Thank you.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message