How to convert a String("yyyy-mm-dd") to the same but in Date format ?

Hi,
can anyone plz tell me how to convert a String to a date format.I'm using MSACCESS database.I want to store this string in the database.So i need to convert it to a date format since the table is designed such a way with date/time type for date field.I used SimpleDateFormat ,but i can't able to convert.The code is given below:
coding:
public String dateconvertion(String strDate)
try
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdfSource.parse(strDate);
SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd ");
strDate = sdfDestination.format(date);
catch(ParseException pe)
System.out.println("Parse Exception : " + pe);
return(strDate);
}

i used prepared statement even now i am getting error like this.....
i have included the prepared statement package also...
my coding:
ResultSet rsdatetemp = null;
PreparedStatement ps = null;
String query ="select distinct itemcode from sales where bill date between ? and ?";
ps = precon.prepareStatement(query);
ps.setDate(1,d1);//d1 and d2 are in date format
ps.setDate(2,d2);
rsdatetemp = ps.executeQuery();
error :
symbol : method setDate(int,java.util.Date)
location: interface java.sql.PreparedStatement
ps.setDate(1,d1);
symbol : method setDate(int,java.util.Date)
location: interface java.sql.PreparedStatement
ps.setDate(2,d2);

Similar Messages

  • How can I set an event that occurs on the same day, not date, every month? Like Thanksgiving is on the third Thursday of November

    On my PowerBook, I was able to set up events to show up on a specific day repeating each month, say the first Thursday.  How can I get that on the iPad 2?

    For your repeating even, I'm assuming this is your Yahoo calendar? that isn't a Firefox issue, I suggest you try to contact yahoo.
    For the other issue, try the following:
    Update to Firefox 15. Then, [[Reset Firefox – easily fix most problems]]

  • How to avoid purchasing multiple things that are the same but different titles

    How can I avoid purchasing multiple things that are the same but have multiple names but is the same purchase for the same use?

    "Things"?  What things?  Apps for keeping track of when to change cat litter?  30 different versions of "twinkle, twinkle little star" played by everything from punk rockers to Gregorian chant?  Videos on the best way to make Christmas cake?

  • How to convert a string value to date

    Dear All,
    I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
    but when i try to convert the variable to date value, I am getting the error as below.
    Please help me......
    PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
    PS C:\script> $passwordSetDate
    PasswordLastSet
    7/15/2014 8:17:24 PM
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    Cannot find an overload for "ParseExact" and the argument count: "3".
    At line:1 char:1
    + $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)

    Dear All,
    I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
    but when i try to convert the variable to date value, I am getting the error as below.
    Please help me......
    PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
    PS C:\script> $passwordSetDate
    PasswordLastSet
    7/15/2014 8:17:24 PM
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    Cannot find an overload for "ParseExact" and the argument count: "3".
    At line:1 char:1
    + $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    In your post you ask how to convert a string value to a date.  The value returned from the Get-AdUser is already a date.  It does not need to be converted.
    Bill has sshown one way to convert a date to a string and there are other methods.  You need to clarify your question.
    If you are really trying ot convert strings to dates then you can start with this:
    [datetime]'01/21/1965 13:33:23'
    Most date strings aer autodetected by the class.
    ¯\_(ツ)_/¯

  • How to convert a String to an Icon

    Hello,
    I'm trying to figure out how to convert a String (specifically one letter) to an Icon for a JTree. The program I am working on uses .png files for the icons at the moment, with each .png being a single uppercase letter. However, recent discussion has us wanting to change to something more dynamic, since we anticipate needing new letters in the near future.
    My task is to modify the current codebase so that the Icons used to identify nodes in the tree are created from a Font within code, rather than reading in .png files. I have done some experimenting with creating a Label with just that String, setting the font and trying to extract the image using calls like createImage(int width, int height) and so on, but so far to no avail.
    If I could figure out how to at least convert the String to an image, I could probably make it work (since I can play around with creating an ImageIcon with that image). Thanks in advance for any help.
    Allan

    Here is some quick and dirty code:
    import java.awt.*;
    import javax.swing.*;
    public class BasicIcon implements Icon {
        private String text;
        public BasicIcon(String text) {
            this.text = text;
        public int getIconWidth() {
            return 16;
        public int getIconHeight() {
            return 16;
        public void paintIcon(Component c, Graphics g,  int x, int y) {
            Color old = g.getColor();
            g.setColor(c.getForeground());
            g.drawString(text, x, y+13);
            g.setColor(old);
        public static void main(String[] args) {
            JPanel cp = new JPanel();
            for (char ch = 'A'; ch < 'F'; ++ch) {
                cp.add(new JButton("letter " + ch, new BasicIcon(String.valueOf(ch))));
            JFrame f = new JFrame("BasicIcon");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }One thing that could be improved is the vertical positioning of the letter in the Icon.
    The x,y values passed into paintIcon are the upper-left hand corner of the icon,
    but the y value needed by drawString is the position of the String's baseline.
    To do it right, use one of Font's getLineMetrics methods and play around with ascent.

  • How to convert a string from upper case to lower case in FOX formula

    Hi Experts,
    How to convert a string from upper case to lower case in FOX formula?
    Thanks,
    Cheers!!!
    PANKAJ

    The last result.append( c ) should be:
    result.append( Character.toLowerCase(c) );

  • How to convert a string from lower case to upper case withour using transla

    Hi all,
    how to convert a string from lower case to upper case withour using translate,
    Thanks in Advance,
    Reddy

    Refer to this related thread
    Re: hi guys this very urgent please help

  • How to convert a String to an array

    Can somebody tell me how to convert a String to an array

    ronisto wrote:
    Can somebody tell me how to convert a String to an arrayI assume you mean to convert it into an array of the individual characters that comprise the String.
    Can you not simply look at the API documentation? Nothing in the String API jumps out at you?
    http://java.sun.com/javase/6/docs/api/index.html

  • How to insert some strings in a query with the clausule 'in' in a procedure

    Hello fellows.
    Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
    I tell us my problem with an example:
    I want to use this select but introducing a variable instead the 'value1', 'value2':
    select * from table1 where field1 in ('value1', 'value2');
    if I declare the variable var1 as:
    TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
    and I use it as:
    select * from table1 where field1 in (TC_VAR1);
    It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
    select * from table1 where field1 in ('value1, value2');
    If I use the data type TABLE, I don't know how to use well:
    TYPE varchar2_table IS TABLE OF VARCHAR2(10);
    tb_var varchar2_table;
    select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
    A curious case is that if I have a sql script (for example script1.sh) with this query:
    select * fromt able1 where field1 in (&1)
    and I invoke this script as
    script1.sh "'''value1'',''value2'''". It works
    Can anybody helps me?.
    Thanks.

    Thanks to all. Really.
    First, sorry for my English. It's horrible. Thank to all for understand it (my English).
    I've resolved my problem with these links:
    ORA-22905: cannot access rows from a non-nested table item
    and
    http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
    At last, I have used someting like this:
    DECLARE
    number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
    BEGIN
    FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
    UNION ALL
    SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
    NULL;
    END LOOP;
    END;
    but first I had to create the type NUM_ARRAY like this:
    CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
    THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
    Edited by: user12249099 on 08-sep-2011 7:37
    Edited by: user12249099 on 08-sep-2011 7:37

  • I just purchased the new Canon SX60 camera. Despite downloading and installing the latest version of Adobe DNG converter, I receive an error message saying that Photoshop CS4 can't open up/convert raw files (.CR2). This is the same file format as used by

    I just purchased the new Canon SX60 camera. Despite downloading and installing the latest version of Adobe DNG converter, I receive an error message saying that Photoshop CS4 can't open up/convert raw files (.CR2). This is the same file format as used by the SX50, with which I never had any problem. Does anyone have a suggestion on how to fix this problem? Thanks.

    Camera Raw plug-in | Supported cameras  I do not see that SX60 as supported. Just how new is the SX60 when was it announces. Its support is not even listed in ACR 8.7 RC

  • How many times can you clean install leopard on the same computer?

    How many times can you clean install leopard on the same computer? Will the leopard dvd run out of installations and not let you install anymore?

    Hi colman Prez;
    Now that the funny comments have been made, I have a serious question and that why are you worry about reinstalling Leopard with an Erase & Install which is what I take that you mean when you say clean install. In actually fact there is no such thing in OS X as a clean install.
    I am curious because in all the years I have used OS X, I have yet to do an Erase & Install yet.
    I know with Windows that they suggest reformatting and reinstalling at the drop of a hat but that isn't true with OS X.
    Allan

  • HT1351 I have a new iPod Touch......I was able to successfully set up a new account, but I want it to be separate from the 800 songs I already have in my iTunes library.  How do I set up a separate library on the same computer?

    I have a new iPod touch; I have an iTunes library of music for an older iPod shuffle.  I'd like to set up the iPod touch for my wife with a separate library of music - I was successful in setting up a separte account, but it seems my 800 songs are still there in the library.  How do a set up a new account on the same computer without bringing along all the music that will clog up her iPod touch?

    There's a few ways of doing it. The following document may be of some help:
    How to use multiple iPods, iPads, or iPhones with one computer

  • How do I get IE 11 to open in the same window on the task bar?

    How do I get IE 11 to open in the same spot on my task bar.  i.e. IE 11 is on my task bar. When I open it, it opens in a new place on the end of the task bar.  Microsoft Outlook, Windows Explorer, Quicken, Adobe, etc,, all on the task bar open
    right at there location on the task bar; not in a new place at the end of the task bar.
    How do I get IE 11, Windows 7, 64 bit to open at the same place as the IE icon???
    Thanks

    Hi,
    Seems a strange issue, How about un-pin IE from the taskbar, then re-pin it to the taskbar for a test?
    If doesn't work, I suggest you turn off IE 11 in "Turn Windows Features on or off", reboot PC, then re-turn on, check the result again.
    Regards
    Yolanda Zhu
    TechNet Community Support

  • I recently purchase an ipad2.  I also have a mac laptop.  Now, when I facetime call using my iphone to my ipad2 or mac, it states busy.  how can i fix this problem?  I have the same apple id e mail for both ipad2 and mac.  it might be getting confuse now.

    I recently purchase an ipad2.  I also have a mac laptop.  Now, when I facetime call using my iphone to my ipad2 or mac, it states busy.  how can i fix this problem?  I have the same apple id e mail for both ipad2 and mac.  it might be getting confuse now.  I want to be able to face time also using my ipad2 to my laptop especially if one of the members of the family is traveling.  Thanks.

    thanks.  your answer was correct, clearer.  I have another question, maybe you can answer.  I just purchase my ipad2 2 days ago.  yesterday, there was a sound.  today there is no sound.  there is a sound only in movies and you tube and music.  but no sound on all apps and keyboards.  I look it up and seems like ther are few that have this problem.  I called walmart coz I bought it there and they told me that they have not heard that before but if I can't fix it, just return it and exchange it with anew one since I have 14 days to do that.  I tried rebooting it and still won't work.  Should I just restore it?

  • How can i share documents with different users on the same mac?

    How can i share documents with different users on the same mac?

    Shared how? The other users can read the documents or you all can read and write the documents?
    The first is easy just place the documents in /Users/Shared anyone can access the files there and the other users will be able to read them.
    The second is a bit trickier.

Maybe you are looking for

  • Error Message while making PO

    Hi, I got a error message while creating PO. "No short text maintained in language DE(Please re-maintain material)" How to go with this? Regards

  • Linux on Oracle: Installation Problem..Odd!!

    I am trying to install oracle 8.0.5 DB server on my RedHat5.2 box with all the necessary rpm install like gcc, cc,lib etc. I am running the orainst from the har disk, I answer all questions and then I see the graph bar appearing and oracle getting in

  • How to specify source directory in File sender adpate using (NFS)?

    Hello experts, I am doing File-PI-Proxy scenario. Input file is available on machine which is within the Network area and FTP is not available on that machine. For this reason I am using the NFS Transport Protocol. In ID File sender I have specified

  • Is Z report needed for FBCJ Balance?

    Hi, There are  5 cash journals  and client needs the balance for all cash journals along with Responsible Person, Balance, Debit and Credit. In FBCJ I couldnt found, is there any report available with above requirement?? Anybody can suggest please. R

  • Z1s has sync issues

    Can anyone please help me? I just received a brand new Xperia z1s from T-mobile and it will not sync with Gmail or my Contacts. I keep receiving "Sign-in errors." It says, "There was a problem connecting with Google Servers... Try again later." My us