PreparedStatement set date sometimes sets the date one day behind

I have a PreparedStatement that sometimes sets the date a day behind. I am saving to a MSSQL DB with a field datetime. I have two identical PreparedStatments, one for insert and one for update. When either is executed, it will sometimes set the date back one day. It's not everytime. Every other or every third one, but it's not consistent. Any help would be appreciated.
ps.setDate(1, Util.parseSqlDate(getParam("CHARGED")));
public class Util {
     public static java.sql.Date parseSqlDate(String datestr) {
          DateFormat sdf = null;
          if (datestr == null)
               return null;
          if (datestr.length() > 8) {
               sdf = new SimpleDateFormat("MM/dd/yyyy");
          else {
               sdf = new SimpleDateFormat("MM/dd/yy");
          java.util.Date d = null;
          try {
           d = sdf.parse(datestr);
          } catch (ParseException e) {
               return null;
          if (d != null) {
               Calendar cal = Calendar.getInstance();
               cal.setTime(d);
               return new java.sql.Date(cal.getTimeInMillis());
          return null;
        protected String getParam(String name) {
          return (getParamArray(name)== null) ? null : getParamArray(name)[0];
     protected String[] getParamArray(String name) {
          return (String[])params.get(name);
     }

traigo wrote:
The database is a datetime field. Then you should be using the appropriate java jdbc time/date methods to access it rather than strings.
We are only storing the date portion. Saving with today's date should produce '2009-12-28 00:00:00.000'.
I just want to set the date to an absolute date (no time value) provided without timezones.Impossible. Since the database datatype is datetime that means that a timezone is always involved.
And java always uses timezones. Ignoring the problem doesn't make it go away.

Similar Messages

  • How to set SPD workflow to send email one day before the Due Date? ?

    I need to add a step in workflow for a item tracking list: send reminder email one day before the due date.
    I thought there is an Action in SPD: wait for [Due Date] to equal [Today]minus one day
    But there is no way to do that.
    I figured may be I need to create a calculated field [cal-date] that set to: =[today] plus one day.
    Then in workflow -
    wait till [Due Date] is equal to [cal-date], and send an email
    What is the formula for the above calculated field [Today] plus one day?

    Hi,
    You can add an approval action( such as Start Approval Process) -> click "Approval" -> go to “Change the behavior of a single task” . Then you will
    see the "When Task expires" stage.
    You can have a look at the blog:
    https://www.nothingbutsharepoint.com/sites/eusp/Pages/5-Steps-to-Enhance-SharePoint-2010-Approval-Workflow.aspx 
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers
    if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]
    Eric Tao
    TechNet Community Support

  • In Firefox 4 how can I cause the date on downloaded files to be the current date? (Some are and some are not. In FF3 the dates were ALWAYS the current ones.)

    In Firefox 4 how can I cause the date on downloaded files to be the current date? (Some are and some are not. In FF3 the dates were ALWAYS the current ones.)
    == This happened ==
    Every time Firefox opened
    == I upgraded to Firefox 4 (beta)

    Firefox 3.6.* and earlier set the downloaded file's modification time to the current time. In Firefox 4.0 the behavior has been changed, if a server returns a timestamp telling when the file was last modified (Last-Modified header), it is used instead.
    You can revert to the previous behaviour by using the [https://addons.mozilla.org/en-US/firefox/addon/93121/ Download Timestamp] add-on.

  • I loos my APPLE ID, I have a new one, how can get access to data stored in the old one?

    I loos my APPLE ID, Now I have a new one, how can get access to data stored in the old one?

    Do you have the email & password of the old Apple ID?

  • When i enter the 2nd data it replaces the 1st one

    when i enter the 2nd data it replaces the 1st one,consequently i losed it.if someone know how i can enter multiple data and save each one in a specific row without losing any data
    thanks

    i was wondering if i will use a lot of clients(for example 2) do i have to use 2 sources not 1 in the Vi.
    now i have in source1:dstp://localhost/emetteur1
                             source2:dstp://localhost/emetteur2
    instead of having 1 source used for all clients:dstp://localhost/emetteur.
    i'm really confused
    and for sending continuously,i have to do it,because each client will not send data just 1 time.i think i missed something in the vi you gave me.what i'm expecting to have is when a client enter"nom- prenom-n candidat" in "emetteur.vi" i"ll see them in a table 1 time in 'recepteur.vi" and when a client enter "nom- prenom-n candidat" in "emetteur1.vi" i'll see them in the 2nd row of the table in "recepteur.vi" and so on.a lof of clients and one receiver without repeating data in reception
    Attachments:
    Pr du tableau à envoyer.zip ‏30 KB

  • Dates one day behind after java upgrade to 1.6.0_27

    I have upgraded from Java 1.5.0_06 to 1.6.0_27
    After the upgrade ,I saw that dates are a day behind.All dates that lie between November 6th to March 10th are correct but dates
    lying between March 10th to November 5th for any year are wrong.(one day behind)
    Is it something to do with DayLight saying.
    I am using GMT-5 Eastern Time(US & Canada) and Server is set to automatically adjust time coressponding to day light saving.
    I checked,I get the date correct from database and in the factory class also it is correct,in the servlet it is correct but my Viewclass which calls this servlet shows date one day behind.
    I am doing no conversion ,the date fetched from database is stored like
    java.sql.Date beginDate= resultSet.getDAte("BeginDate")
    Schedule.setBegindate(beginDate)
    In the Schedule Object ,the beginDAte is of type Date.
    I am adding all dates to a treeset.I do a printout just after setting,it is correct
    But in my view class ,its one day behind,no manipulation is done.Dont know why is the day incorrect.
    IS it because of Java version.
    Please help

    As I mentioned That
    My view class TestView code is some what like this
    public class TestView extends JFrame
    public TestView(URL url, AppletContext appletContext)
    this.appletContext = appletContext;
    SwingUtilities.invokeLater(new Runnable() {
    public void run()
    testCommand test= new GetDatesCommand();//call factory class which fetches result from database
    Object returnValue = TestUtils.callServlet(test);//calls the servlet .
    if( returnValue instanceof TreeSet )
    TreeSet testSet= (TreeSet)returnValue;
    TestView.setDate(testSet));
    I am calling this constructor of viewtest class from my LoginTestApplet
    public class LoginTEstApplet extends JApplet
    public LoginApplet()
    TimeZone.setDefault(TimeZone.getTimeZone("EST"));
    LoginTestActionperformed()
    new testView(getDocumentBase(), this.getAppletContext());
    As I mentioned the values of dates as fetched from database ,factory class and getDatesCommand class prints fine.Its just inside this class after the call to servlet ,it displays wrong date.
    I have an applet ,LoginTestApplet which is the entry point for my application.Inside the default constructor ,I am doing
    TimeZone.setDefault(TimeZone.getTimeZone("EST"));
    I have mentioned in my second post what results it shows for getDefaults.
    I know its very strange ,the dates gets one day behind immedately only in the view class not in the servlet or the factory class.
    Please let me know if I need to post some more data .

  • Log "date completed" to the date when "completed" was updated to "yes

    Hello,
    I want a workflow to fill "date completed" with the date when "completed" is updated to "yes". I am using Sharepoint Designer 2013.
    I have been through hours of research but I could not find any post clear enough to me. Please do not refer me to ancient threads.
    Thanks!
    PS: Below find what I have tried. It does not return anything in "date completed" in my task list...

    Hi Edouard,
    According to your description, my understanding is that you want to set the ‘CompletedDate’ when the ‘Completed’ is Yes.
    You can set the workflow like the screenshot below:
    And set the workflow started when a new item is created or an item is changed.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Purchased a new Apple TV and the remote double clicks each time I press the button. It worked fine during set up and for the first two days.  I have since moved it and this problem started. Restarted,reset,unplugged,change remotes, no change.Help please.

    Purchased a new Apple TV and the remote double clicks each time I press the button. It worked fine during set up and for the first two days.  I have since moved it and this problem started. Restarted,reset,unplugged,changed remotes, no change. Latest software update. This is really annoying.  iPhone remote app works just fine.  Any suggestions?

    That's one of the weird things.. it recognizes it maybe 10% of the time. And usually, only after I do the two-button reset. Problem is.. since it won't charge above 2%, anytime I try to do a restore or anything like that using iTunes, my device shuts off and I lose whatever progress I'd made.
    So, an update... after reading through a bunch of similar complaints (there are literally 1000's of them so there's NO WAY this isn't somehow ios7 related, thanks a lot APPLE ) I decided to try a restore in recovery mode. After 3 hours and several disconnections... I ended up having to just set it up as a new iPad, as the restore did nothing. Weirdly though... as I was doing the restore in recovery mode.. I noticed I'd gotten up to a 10% charge.. higher than it's been since September, so after setting it up as a new device, I turned it off and plugged it in using the wall charger. 2 hours later and I was up to 38%. Still not great, as my iPad, before ios7 could've fully charged twice in the amount of time it took for me to now get 28% more of a charge. And that's with a fully cleaned out device.. so that really ***** and I'm now more confused than ever.
    But I'm gonna leave it overnight charging and see what I come up with tomorrow. Sadly, when I paid $600 for it in February, I never expected to have to play "wait and see" with it...

  • I scanned an old photo but the date displayed is today, I want the date to be the date the photo was taken.  How do I change the date of the photo in iPhoto 11?

    I scanned an old photo but the date displayed is today, I want the date to be the date the photo was taken.  How do I change the date of the photo in iPhoto 11?

    There are two kinds of metadata involved when you consider jpeg or other image file.
    One is the file data. This is what the Finder shows. This tells you nothing about the contents of the file, just the File itself.
    The problem with File metadata is that it can easily change as the file is moved from place to place or exported, e-mailed, uploaded etc.
    Photographs have also got both Exif and IPTC metadata. The date and time that your camera snapped the Photograph is recorded in the Exif metadata. Regardless if what the file date says, this is the actual time recorded by the camera.
    Photo applications like iPhoto, Aperture, Lightroom, Picasa, Photoshop etc get their date and time from the Exif metadata.
    When you export from iPhoto to the Finder new file is created containing your Photo (and its Exif). The File date is - quite accurately - reported as the date of Export.
    However, the Photo Date doesn't change.
    The problem is that the Finder doesn't work with Exif.
    So, your photo has the correct date, and so does the file, but they are different things. To sort on the Photo date you'll need to use a photo app.

  • Power view couldn't load the model or data source because the data source type is not supported

    Hi,
    I have SQL 2012 standard edition in my local. I have developed SSAS & deployed in local. I have been asked to develop power view report in excel 2013 using this SSAS. But when I tried to do in Excel 2013 professional Plus, I am getting below error:
    Power view couldn't load the model or data source because the data source type is not supported.
    Does power view is supported in standard edition of SQL or it requires Business/Enterprise edition of SQL server?
    Thanks in advance

    What type of SSAS install are you using?
    PowerView in Excel 2013 currently only supports Tabular data sources.
    Only PowerView in Sharepoint 2013 supports both Tabular and Multi-Dim data sources. (provided you have the required Sharepoint and SQL updates installed)
    http://darren.gosbell.com - please mark correct answers

  • Will any of DDL command trigger a data flush from the data buffer to disk?

    Will any of DDL command trigger a data flush from the data buffer to disk?---No.164

    I mean if I issue the DDL commands Such as DROP, TRUNCAE, CREATE, Can these commands trigger a data flush action?

  • Can you add the data information to the data points in a chart

    I am trying to add the data information to the data points in a line chart.  can this be done?

    You can add Value labels to the series to show the numerical value at each data point. The control is in the Series section of the Chart Inspector (see green arrow).
    If you are asking about text labels, such as the "Test 1", "Test 2", etc. in column A of the table, You can add these by copy/paste into a text box placed in front of the chart, or use a formula ( =Table 1::A1 ) to transfer the text into a single cell table placed appropriately on the chart.
    Using single cell tables will allow automatic updating of the label if the content of the Table 1 cell(s) changes. Neither method will automatically reposition the label if there's a change in the data feed to the chart.
    Regards,
    Barry

  • Can SPM 2.1 or 3.0 BI standard  data model read the data form existing BI P

    Hi,
    I am curious to find out, can SPM 2.1 or 3.0 BI standard  data model read the data form existing BI Procurement  (Cubes and DSO's) with no customization mapping?
    i know SPM 2.0 do not have that flexibility (Standard data model can read from BI), we would have to map transformation.
    I would appreciate your response..
    Rgds,
    Mahesh

    Hi Mahesh,
    What you can do in SPM30 is create an export datasource for existing BI objects and use them as direct datasource in SPM using template mapping.
    Direct transformations from BI object to SPM objects is not provided.
    Regards,
    Divyesh

  • Data deleted in ODS, data coming from the data source : 2LIS_11_VASCL

    Friends,
    I have situation :
    Data deleted in ODS, data coming from the data source : 2LIS_11_VASCL.
    when for the above ods and the data source when trying to delete the request whole data got delted.
    All the data got deleted in the fore ground. no background job has been generated for this.
    I ma really worried abt this issues. can u please tell me what should be the possibilities for this issue.
    Many Thanks
    VSM

    Hi,
    I suppose you want to know the possibilitiy of getting the data.
    If the entire data is being deleted, you can reload the data from source system.
    Load the setup table for your application. Then carry out init request.
    Please note that you would have to take a transaction-free period for carrying out this activity so that no data is missed.
    Once this is done, delta queues will again start filling up.

  • HT201441 I restored my phone and now it is asking me to activate it and i am trying but it is saying i cant activate my phone with my own id that i have to use the id that i used to set up my iphone the very first day i got it but that is the id. help ple

    I restored my phone and now it is asking me to activate it and i am trying but it is saying i cant activate my phone with my own id that i have to use the id that i used to set up my iphone the very first day i got it but that is the id. help please

    You can try calling Apple support at 0800-761-0880 and explaining the situation to them. Perhaps there will be something they can do to help. Try asking to speak with a Customer Relations representative, though I don't know if they have them in Brazil.
    Regards.

  • How to get from Apple (officially) details on my iphone 5 (knowing the serial number): model, date of sale, the date of activation, etc.

    How to get from Apple (officially) details on my iphone 5 (knowing the serial number): model, date of sale, the date of activation, etc. I bought a new iphone 5 on ebay.com - he was used. For a decision on my case ebay asks for this information ...

    Apple will never reveal that info to you, since you were not the originally purchaser. However, you can get the date of sale by entering the SN here:
    https://selfsolve.apple.com/agreementWarrantyDynamic.do
    Warranty starts on the date of sale, which is most likely the date of activation, but not necessarily so.

Maybe you are looking for