Hi
assuming you cant use the JMeter __time function for whatever you need (
http://jakarta.apache.org/jmeter/usermanual/functions.html)
in Beanshell
import java.util.Date;
import java.text.SimpleDateFormat;
long time = SampleResult.getStartTime();
Date d = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String s = sdf.format(d);
Look at
http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html
for the SimpleDateFormat patterns that can be used
regards
deepak
On Tue, Feb 8, 2011 at 12:38 PM, Michel Duijvestijn <[email protected]>wrote:
> I'm trying to build a beanshell assertion that writes detailed error
> information to a file, including the start time of the sample with the
> error.
> I managed to get the starttime, using SampleResult.getStartTime(),
> which gives me the starttime as Long.
> How do I format this in a more readable format?
> Being unexperienced in Beanshell and Java-programming I found and
> tried "sampleResult.getStartTime().SimpleDateFormat()", but that gives
> an error message that the beanshell interpreter couldn't find the
> class:
> "Error in method invocation: Method SimpleDateFormat() not
> found in class'bsh.Primitive'"
> Do I need to import the SimpleDateFormat class first?
> Do I need to convert the getStartTime-result to a Java-date-object to
> be able to format it using SimpleDateFormat?
> Or should I do it in a complete different way?
>
> Your help is very much appreciated!
> --
> Michel Duijvestijn
> Rotterdam University
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>