How can I parse a String to Timestamp type??

Hi, I receive a String time="07.05.2007 12:30:20", I want to parse this String to a Timestamp type, how to do that?

I use the following code to parse String to Date, but it throw unhandled exception, type parse exception. It seems the parse source "07.05.2007 12:30:10" has problem.
SimpleDateFormat sdfTest=new SimpleDateFormat("dd.mm.YYYY HH:mm:ss");
     Date newDate=sdfTest.parse("07.05.2007 12:30:10");
Please give me some suggestion.
Message was edited by:
Mellon

Similar Messages

  • How can I parser a String with javax.xml.parsers.DocumentBuilder?

    Normally the DocumentBuilder can parse files, InputSource,InputStream or uri. but what if I want to parse an editing String the user created in an EditPane or JTextComponent?

    new InputSource(new StringReader(theString))

  • How can I send multiple string commands into a VISA write?

    Hi Fellow LabVIEW users
    I am very new to LabVIEW (2.5 months) so please forgive me if my lingo is not up to par.
    How can I send multiple string commands to a VISA write. For example each string command looks like this
    1) 3A00 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0033 (Scenario 1)
    2) 3A01 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0034 (Scenario 2)
    3) 3A01 0000 0000 33FF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0067 (Scenario 3).
    and so on and so forth. And there are a number of scenarios.
    Each String scenario will give a different string output which will be interpreted differently in the front panel.
    Right now I have to manually change the string commands on the front panel to give me the desired output. How can I do this without manually changing the commands i.e. hard coding each scenario into the block diagram?
    Thanks, any feedback will help.
    mhaque

    Please stick to your original post.

  • I have result after execution of OperationBinding. How can i parse and store in list.

    I have result after execution of operation binding. how can i parse and store in list

    Hi,
    I Thought u have custom method in AM which returns List Data type. What is the requirement exactly, bcz commit operation have void return type.
    Ex: create custom method in AMimple class
    public List sampleData(){
    // code here to set the values in List object.
    now expose the above method in client interface. Then add the Method action binding in pageDef file and execute the below code in managed bean
    OperationBinding operationBinding = (OperationBinding)bindings.getOperationBinding("sampleData");
                List result =(List) operationBinding.execute();
    Thanks
    Nitesh

  • How can i extract data strings (temp. press. rel.hum etc) using a Virtual interface through an RS-232 connection​?

    How can i extract data strings (temperature, pressure, relative humidity etc) using a Virtual interface through an RS-232 connection?

    Try this.  It is in LV 8.5.
    Note the double % in the format string.  This is so the % in the input string is treated as a percent rather than a code.
    You may also have to work with the line feed characters in case they are different in the string coming in compared to how the string shows up in the web browser.
    Message Edited by Ravens Fan on 02-12-2008 10:19 PM
    Attachments:
    Example_BD.png ‏4 KB
    Untitled 11.vi ‏9 KB

  • How can I convert a string to a seperated characters?

    How can I convert a string to a separated characters without using array?
    such as: input = String "word"
    output =
    w
    o
    r
    d
    Thanks

    A string is stored internally in individual characters.
    The String class has a method 'charAt(int index)' which returns the character at that index so using a for loop..
    String s = "word";
    for(int counter=0; counter < s.length(); counter++)
    System.out.println(s.charAt(counter));
    HTH

  • How can i write a string into a specified pos of a file?

    How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
    for example:
    the content of file is:
    name=123
    state=456
    i want to modify the value of name with 789
    (write to file without read all file into ram)
    How can i do it? thank you

    take this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
    import java.io.*;
    import java.util.*;
    * Copyright (c) 2002 Frank Fischer <[email protected]>
    * All rights reserved. See the LICENSE for usage conditions
    * ObjectProperties.java
    * version 1.0, 2002-09-12
    * author Frank Fischer <[email protected]>
    public class ObjectProperties
         // the seperator between the param-name and the value in the prooperties file
         private static final String separator = "=";
         // the vector where we put the arrays in
         private Vector PropertiesSet;
         // the array where we put the param/value pairs in
         private String propvaluepair[][];
         // the name of the object the properties file is for
         public String ObjectPropertiesFileName;
         // the path to the object'a properties file
         public String ObjectPropertiesDir;
         // reference to the properties file
         public File PropertiesFile;
         // sign for linebreak - depends on platforms
         public static final String newline = System.getProperty("line.separator");
         public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
         //     System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
              this.ObjectPropertiesFileName = ObjectPropertiesFileName;
              this.ObjectPropertiesDir = ObjectPropertiesDir;
              // reference to the properties file
              PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
              // vector to put the param/value pair-array in
              PropertiesSet = new Vector();
         //     System.out.println("Properties File Backup wird erzeugt: "+name);
              backup();
         //     System.out.println("Properties File wird eingelesen: "+PropertiesFile);
              try
                   //opening stream to file for read operations
                   FileInputStream FileInput = new FileInputStream(PropertiesFile);
                   DataInputStream DataInput = new DataInputStream(FileInput);
                   String line = "";
                   //reading line after line of the properties file
                   while ((line = DataInput.readLine()) != null)
                        //just making sure there are no whitespaces at the beginng or end of the line
                        line = cutSpaces(line);
                        if (line.length() > 0)
                             //$ indicates a param-name
                             if (line.startsWith("$"))
                                  // array to store a param/value pair in
                                  propvaluepair = new String[1][2];
                                  //get the param-name
                                  String parameter = line.substring(1, line.indexOf(separator)-1);
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  parameter = cutSpaces(parameter);
                                  //get the value
                                  String value = line.substring(line.indexOf(separator)+1, line.length());
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  value = cutSpaces(value);
                                  //put the param-name and the value into an array
                                  propvaluepair[0][0] = parameter;
                                  propvaluepair[0][1] = value;
                             //     System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
                                  //and finaly put the array into the vector
                                  PropertiesSet.addElement(propvaluepair);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   // System.out.println("in ObjectProperties");
         // function to be called to get the value of a specific paramater 'param'
         // if the specific paramater is not found '-1' is returned to indicate that case
         public String getParam(String param)
              // the return value indicating that the param we are searching for is not found
              String v = "-1";
              // looking up the whole Vector
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = new String[1][2];
                   // trying to get out the array from the vector again
                   s = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we look up the value and write it in the return variable
                        v = s[0][1];
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // giving the value back to the calling procedure
              return v;
         // function to be called to set the value of a specific paramater 'param'
         public void setParam(String param, String value)
              // looking up the whole Vector for the specific param if existing or not
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we remove the param/value pair so we can add the new pair later in
                        PropertiesSet.removeElementAt(i);
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // if we land here, there is no such param in the Vector, either there was none form the beginng
              // or there was one but we took it out.
              // create a string array to place the param/value pair in
              String n[][] = new String[1][2];
              // add the param/value par
              n[0][0] = param;
              n[0][1] = value;
              // add the string array to the vector
              PropertiesSet.addElement(n);
         // function to save all data in the Vector to the properties file
         // must be done because properties might be changing while runtime
         // and changes are just hold in memory while runntime
         public void store()
              backup();
              String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
              try
                   //opening stream to file for write operations
                   FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
                   DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
                   // looping over all param/value pairs in the vector
                   for (int i=0; i<PropertiesSet.size(); i++)
                        //the String i want to read the values in
                        String s[][] = new String[1][2];
                        // trying to get out the array from the vector again
                        s = (String[][]) PropertiesSet.elementAt(i);
                        String param = "$"+s[0][0];
                        String value = s[0][1];
                        outtofile += param+" = "+value+newline;
                   outtofile += newline+"#end of file"+newline;
                   try
                        PropertiesDataOutput.writeBytes(outtofile);
                   catch (IOException e)
                        System.out.println("ERROR while writing to Properties File: "+e);
              catch (IOException e)
                   System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
         // sometimes before overwritting old value it's a good idea to backup old values
         public void backup()
              try
                   // reference to the original properties file
                   File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
                   File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
                   //opening stream to original file for read operations
                   FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
                   DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
                   //opening stream to backup file for write operations
                   FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
                   DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
              //     String content = "";
                   String line = "";
                   // do till end of file
                   while ((line = OriginalFileDataInput.readLine()) != null)
                        BackupFileDataOutput.writeBytes(line+newline);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   System.out.println("this is a serious error - the server must be stopped");
         private String cutSpaces(String s)
              while (s.startsWith(" "))
                   s = s.substring(1, s.length());
              while (s.endsWith(" "))
                   s = s.substring(0, s.length()-1);
              return s;
         public String createDate(String seperator)
              Date datum = new Date();
              String currentdatum = new String();
              int year, month, date;
              year = datum.getYear()+1900;
              month = datum.getMonth()+1;
              date = datum.getDate();
              currentdatum = ""+year+seperator;
              if (month < 10)
                   currentdatum = currentdatum+"0"+month+seperator;
              else
                   currentdatum = currentdatum+month+seperator;
              if (date < 10)
                   currentdatum = currentdatum+"0"+date;
              else
                   currentdatum = currentdatum+date;
              return currentdatum;
         public String createTime(String seperator)
              Date time = new Date();
              String currenttime = new String();
              int hours, minutes, seconds;
              hours = time.getHours();
              minutes = time.getMinutes();
              seconds = time.getSeconds();
              if (hours < 10)
                   currenttime = currenttime+"0"+hours+seperator;
              else
                   currenttime = currenttime+hours+seperator;
              if (minutes < 10)
                   currenttime = currenttime+"0"+minutes+seperator;
              else
                   currenttime = currenttime+minutes+seperator;
              if (seconds < 10)
                   currenttime = currenttime+"0"+seconds;
              else
                   currenttime = currenttime+seconds;
              return currenttime;

  • How can I re-organize String lines

    Hello My String consists of random lines. Every line has an priority number. Example of a String:
    Done     id     pri     created          finished     description     
         000     1     2006-12-11     -          job     
    x     001     2     2006-12-11     -     do this     
         002     3     2006-12-11     -          work
    x     003     0     2006-12-11     -          some
         004     2     2006-12-11     -          thing
         005     1     2006-12-11     -          reads
         006     0     2006-12-11     -          here
    Every "token" is seperated by \t (done \t id \t ....\t 000 \t 1 \t 2006-12-12 \t...)
    How can I organize the String and save it to another String so that pri-values are in a descending order:
    Done     id     pri     created          finished     description     
    002     3     2006-12-11     -          work
    x     001     2     2006-12-11     -     do this     
    004     2     2006-12-11     -          thing
    000     1     2006-12-11     -          job     
    005     1     2006-12-11     -          reads
    x     003     0     2006-12-11     -          some
         006     0     2006-12-11     -          here

    I'm trying but I don't know what I'm doing
    import java.io.*;                
    import java.util.*;                    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    import java.util.Comparator;
    public class Start {
    public static void main(String[] args) throws IOException {
    sort();
    public static void sort() throws IOException  {
         class Work implements Comparable {
         String id;
         int pri;
         String d1;
         String d2;
         String job;
         public Work(String id, int pri, String d1, String d2, String job){
              this.id = id;
              this.pri = pri;
              this.d1 = d1;
              this.d2 = d2;
              this.job = job;
         BufferedReader reader = new BufferedReader(new FileReader("Tehtava.txt"));
         //BufferedWriter writer = new BufferedWriter(new FileWriter("Tempo.txt"));
         String lookingFor3 = "-";
         String line = null;
         while ((line = reader.readLine()) != null) {     //---------------z
                   String[]result = line.split("\t");
                   List tasks = new ArrayList();
                   if (result[4].equals(lookingFor) == true) {     
                   tasks.add(new Work(line));     
                   continue;
                   public int getpri()     {
                   return pri;          }
                   public int compareTo(Object o)     {
                   Work otherWork = (Work) o;
                   return this.getpri().compareTo(otherWork.getpri());     }
              Collections.sort(tasks); //-------------------x
              System.out.print(tasks); //------------------x
              //reader.close();
    }I don't know what but Where and I'm getting errors like:
    <identifier> expected
    for lines ------------x
    illegal start of type:
    for line -------------z

  • Dear sir! How can i judge a string's encoding?

    Dear sir! How can i judge a string's encoding?
    Now i receive a string !but i do not known what encoding this string is? I want a method to judge the encoding.
    Thank you!

    Strings in Java are by definition in Unicode. If you want to convert them to a specific encoding, you can do this:
    String yenSign = new String("\u00A5");
    byte[] yenByteArray = yenSign.getBytes("UTF8");
    Now yenByteArray is encoded into bytes using UTF-8.

  • RMAN-06466: error parsing configuration string (CONFIGURE DEVICE TYPE DISK

    Hi All
    Windows 2003 and 10.2.0.4
    I get the following message when executing show all; connected to rman
    (I have used grid control 11g for the first configuration of rman. Not sure if it has an impact.)
    RMAN configuration parameters are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
    CONFIGURE BACKUP OPTIMIZATION OFF; # default
    CONFIGURE DEFAULT DEVICE TYPE TO DISK;
    CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of show command at 09/22/2011 16:04:11
    RMAN-12010: automatic channel allocation initialization failed
    RMAN-06466: error parsing configuration string (CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;)
    RMAN-01005: syntax error: found "backup": expecting one of: "clear, parallelism"
    RMAN-01007: at line 1 column 28 file: Configuration Row
    RMAN>
    Reading the manual Database Backup and Recovery Basics
    I should be able to configure it like this
    RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01005: syntax error: found "backup": expecting one of: ";"
    RMAN-01007: at line 1 column 42 file: standard input
    Anyone that can help me with this ?
    Appreciate your feedback.
    Thanks
    Magnus

    What happens if you type "CONFIGURE DEVICE TYPE DISK CLEAR;" ?

  • How can we give the Data Format (File Type ) in Runtime

    Hi all,
    How can we give the Data Format (File Type ) in Runtime for the following method,
    cl_gui_frontend_services=>gui_download.
    Thanks in advance
    Sri

    There is a filetype parameter which you can set
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
    *    BIN_FILESIZE              =
        filename                  =
    *    FILETYPE                  = 'ASC'
    *    APPEND                    = SPACE
    *    WRITE_FIELD_SEPARATOR     = SPACE
    *    HEADER                    = '00'
    *    TRUNC_TRAILING_BLANKS     = SPACE
    *    WRITE_LF                  = 'X'
    *    COL_SELECT                = SPACE
    *    COL_SELECT_MASK           = SPACE
    *    DAT_MODE                  = SPACE
    *    CONFIRM_OVERWRITE         = SPACE
    *    NO_AUTH_CHECK             = SPACE
    *    CODEPAGE                  = SPACE
    *    IGNORE_CERR               = ABAP_TRUE
    *    REPLACEMENT               = '#'
    *    WRITE_BOM                 = SPACE
    *    TRUNC_TRAILING_BLANKS_EOL = 'X'
    *  IMPORTING
    *    FILELENGTH                =
      changing
        data_tab                  =
    *  EXCEPTIONS
    *    FILE_WRITE_ERROR          = 1
    *    NO_BATCH                  = 2
    *    GUI_REFUSE_FILETRANSFER   = 3
    *    INVALID_TYPE              = 4
    *    NO_AUTHORITY              = 5
    *    UNKNOWN_ERROR             = 6
    *    HEADER_NOT_ALLOWED        = 7
    *    SEPARATOR_NOT_ALLOWED     = 8
    *    FILESIZE_NOT_ALLOWED      = 9
    *    HEADER_TOO_LONG           = 10
    *    DP_ERROR_CREATE           = 11
    *    DP_ERROR_SEND             = 12
    *    DP_ERROR_WRITE            = 13
    *    UNKNOWN_DP_ERROR          = 14
    *    ACCESS_DENIED             = 15
    *    DP_OUT_OF_MEMORY          = 16
    *    DISK_FULL                 = 17
    *    DP_TIMEOUT                = 18
    *    FILE_NOT_FOUND            = 19
    *    DATAPROVIDER_EXCEPTION    = 20
    *    CONTROL_FLUSH_ERROR       = 21
    *    NOT_SUPPORTED_BY_GUI      = 22
    *    ERROR_NO_GUI              = 23
    *    others                    = 24

  • How can i parse the number from the string each time automatic ?

    I have this two lines:
    last_file = fi[fi.Length - 1].FullName;
    string lastFileNumber = last_file.Substring(86, 6);
    In last_file i have: C:\\Users\\chocolade1972\\AppData\\Local\\mws\\My Weather Station\\radar_temp_directory\\radar000142.gif
    So i counted and found that the number in this case 000124 is starting from index 86 and length 6
    But for example on my brother pc the directory is shorter the name is not chocolade1972 so the index is incorrect.
    It's not 86.
    How can i use the Substring to find the correct index every time on any pc that have a differenet directory length ?
    In this case it's working fine on my pc for any image i can get the number no problems. But i want it to work also on other pc's.

    You can use Regex to match the filename you want. 
    Like Giovhan suggested you can first get the filename like:
    string result;
    result = Path.GetFileName(fileName);// in your example result = radar000142// in my regex I assume that a file can have a number of digits between 5 to 7 digits.Regex filenameRegex = new Regex("\d{5,7}");string number = filenameRegex.Match(result).Value;// by that way you can retrieve all numbers between 5 to 7 digits regardless of filename whether contains all 6 digits// or file that may contain 5 or 7 digits // You can play with the Regex code to decrease or increase number of digits by changing the numbers

  • How do i parse a string

    Can somebody tell me the function used to parse a string and how it works? All I want to do is seperate the string 'AG-01' into another string 'AG-' and an int '01'. I have been through numerous resources and have found nothing at all on parsing functions.

    This in one way:
    String txt = "AG-01";
    String first = txt.substring(0,3);
    int second = Integer.parseInt(txt.substring(3,5));
    %>
    First string:<%=first%>
    Second int :<%=second%>
    Bye
    Beck74

  • How can I convert a String into an int?

    I need to use command-line args. So I enter "java Main 123" and I want to use 123 not as a String but as an int.
    How can I convert it into an int?
    Thank You!!
    Sprocket

    Example method (you don't need to use a method unless you do this a lot)
    private int stringTOInt (String aString)
    int result = 0;
    try
    result = Integer.parseString(aString);
    catch (Exception ex)
    System.out.println ("Failed to convert string " + aString + " to int.");
    return result;
    }

  • How can i convert the firefox-history-timestamp in places.sqlite into a normal date format? The firefox-timestamp is not equivalent to the unix-timestamp, that's why I ask. I could not find a conversion function. Does anyone know something about this?

    As I opened the places.sqlite with an sqlite-editor I found out that firefox saves the last_visit_date via a timestamp which is 16 digits long. I realized that the first 10 digits are similar to the corresponding unix-timestamp but not equal. So.. how can i convert the firefox-timestamp into a normal date? Or into the corresponding unix-timestamp?

    Write a bash script or 'C' program to change the date format and then use the sql update function to receive the stdio output 'where date_field='embeded date value'.

Maybe you are looking for

  • Flakey LCD after adding thuderbolt drive

    I have the latest version 17" MBP.  I have been using the mini display adapter to DVI to run a Gateway HD Display LP2407.  It works fine, but I purchased a G-Tech thunderbolt drive (8TB) and have a thunderbolt cable going from the mini display.thunde

  • Mail JPEG photo attachments

    Greetings. I send variously-sized photo files as JPEGs attached to email; some recipients can open them with no problems, but others have significant difficulties. Most recently, a customer has claimed that she can only open my JPEG photo file attach

  • Email notification only working with mailto:

    I've found that the mail notification is working, but the only way to get it working is to use the prefix 'mailto:' when specifying the email address to send the notification to.

  • Need thoughts on adding caption

    I have finished scanning a number of old family photos and have used Adobe Photoshop Elements 9 (PSE9) to "tag" and add "captions" to each photo. The photos vary in size and are saved in tif format. All of the work I have done so far was using the Or

  • MDC error message -  'incorrect search policy'

    Having re-installed Mountain Lion on my MDC and Clients and NOT deleted any Xsan Sys Prefs and KeyChain passwords, finally managed to get all my clients Authorized OK. Then attached my Retina Display MBP through a Thunderbolt to FC convertor box (Pro