Problems with parsing a data - thought this was simple, but somewhere it's causing grief
At the top of the file I have
import com.screenscraper.common.*;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.lang.*;
import java.util.*;
import java.io.*;
Then I am trying to do
SimpleDateFormat formatter = new SimpleDateFormat( "MMM d, yyyy");
Date DRecord = new Date((Date)formatter.parse( myDataRecord.get("ORDERCHANGEDATE")));
And I am getting
An error occurred while processing the script: BrickLinkCheckArrivalProcessDetailedEnd
The error message was: class bsh.EvalError (line 27): new Date ( ( Date ) formatter .parse ( myDataRecord .get ( "ORDERCHANGEDATE" ) ) ) -- Typed variable declaration : Constructor error: Can't find constructor: class java.util.Date
Which makes no sense to me, since this code was working before. BUT before I was just using Date.parse since the system I was interfacing with used standard dates, now it changed!!
I have some code to do the
I have some code to do the same thing:
import java.util.Date;
import java.util.Locale;
import java.util.Calendar;
import java.text.SimpleDateFormat;
// For date formatting
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy kk:mm:ss");
// Get the posted time
lastPosted = fixString(session.getVariable("POSTED"));
if (lastPosted==null)
lastPosted = "01-Jan-2009 00:00:00";
lastPosted = session.reformatDate(lastPosted, "d-M-Y H:i:s");
// Parse to date
Date lastPosted = sdf.parse(lastPosted);
oldestDesired = session.getVariable("OLDEST_DESIRED");
Notice that I use the session.refomatDate in there that accepts 2 parameters. In this case, sometimes the date says 10 minutes ago or 2 hours ago, or if older it shows the date so I use that make sure the date is normalized before I try to parse it.
Oopps, so simple - removed
Oopps, so simple - removed the 'new Date...' and just did an assignment, weird, that was not part of my recent changs, but obviously it caused some grief. Oh well, THANKS!!