How to parse timestamp data

Hi,
I am not able to parse timestamp data. I am bringing this timestamp from AD through LDAP attribute through java code. I want date and time from this timestamp so that I can compare it with another date and time and get the difference between the two.
If anybody knows the solution for this then please let me know.
Thanks,
Kalpana.

Hi Kalpana,
try this to convert AD date to java date format
     final long FILETIME_EPOCH_DIFF = 0xa9735dcc400L;
     final long HUNDRED_NANO_PER_MILLI_RATIO = 10000L;
     long activeDirDate = 129476773898586231L;
     long l1 = activeDirDate / 10000L;
     long l2 = l1 - FILETIME_EPOCH_DIFF;
     Date newdate = new Date(l2);
     System.out.println("AD Date is in Java Date format : "+newdate);
Thanks,
Pallavi

Similar Messages

  • How to add TIMESTAMP data type in  Enterprise Architect...?

    Hi all
    There is no data type of timestamp in Enterprise Architech. There is only
    DATE type. I have ERD prepared from Enterprise Architech. How to modify
    DATE type to TIMESTAMP type.
    How to add TIMESTAMP data type in Enterprise Architect or in ERD ?
    Thanks in advance,
    Pal

    Have you asked this question of the vendor of Enterprise Architect? They may have a later version that supports the various TIMESTAMP data types. If your ERD tool doesn't support a data type, other than talking to the vendor or working around the problem (i.e. generate DDL to a text file and edit it before applying it to the database), you're probably out of luck.
    Justin

  • How to parsing xml data in sql statement??

    Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
    <Employees xmlns="http://TargetNamespace.com/read_emp">
       <C1>106</C1>
       <C2>Harish</C2>
       <C3>1998-05-12</C3>
       <C4>HR</C4>
       <C5>1600</C5>
       <C6>10</C6>
    </Employees>
      Then how to extract the data in above xml column data using SQL statement...

    Duplicate post
    How to parsing xml data in sql statement??

  • How to parse xml data into java component

    hi
    everybody.
    i am new with XML, and i am trying to parse xml data into a java application.
    can anybody guide me how to do it.
    the following is my file.
    //MyLogin.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    class MyLogin extends JFrame implements ActionListener
         JFrame loginframe;
         JLabel labelname;
         JLabel labelpassword;
         JTextField textname;
         JPasswordField textpassword;
         JButton okbutton;
         String name = "";
         FileOutputStream out;
         PrintStream p;
         Date date;
         GregorianCalendar gcal;
         GridBagLayout gl;
         GridBagConstraints gbc;
         public MyLogin()
              loginframe = new JFrame("Login");
              gl = new GridBagLayout();
              gbc = new GridBagConstraints();
              labelname = new JLabel("User");
              labelpassword = new JLabel("Password");
              textname = new JTextField("",9);
              textpassword = new JPasswordField(5);
              okbutton = new JButton("OK");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 5;
              gl.setConstraints(labelname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 5;
              gl.setConstraints(textname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 10;
              gl.setConstraints(labelpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 10;
              gl.setConstraints(textpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 15;
              gl.setConstraints(okbutton,gbc);
              Container contentpane = getContentPane();
              loginframe.setContentPane(contentpane);
              contentpane.setLayout(gl);
              contentpane.add(labelname);
              contentpane.add(labelpassword);
              contentpane.add(textname);
              contentpane.add(textpassword);
              contentpane.add(okbutton);
              okbutton.addActionListener(this);
              loginframe.setSize(300,300);
              loginframe.setVisible(true);
         public static void main(String a[])
              new MyLogin();
         public void reset()
              textname.setText("");
              textpassword.setText("");
         public void run()
              try
                   String text = textname.getText();
                   String blank="";
                   if(text.equals(blank))
                      System.out.println("First Enter a UserName");
                   else
                        if(text != blank)
                             date = new Date();
                             gcal = new GregorianCalendar();
                             gcal.setTime(date);
                             out = new FileOutputStream("log.txt",true);
                             p = new PrintStream( out );
                             name = textname.getText();
                             String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
                             p.println(entry);
                             System.out.println("Record Saved");
                             reset();
                             p.close();
              catch (IOException e)
                   System.err.println("Error writing to file");
         public void actionPerformed(ActionEvent ae)
              String str = ae.getActionCommand();
              if(str.equals("OK"))
                   run();
                   //loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    hi, thanks for ur reply.
    i visited that url, i was able to know much about xml.
    so now my requirement is DOM.
    but i dont know how to code in my existing file.
    means i want to know what to link all my textfield to xml file.
    can u please help me out. i am confused.
    waiting for ur reply

  • How to parse the date value for the string 2003-04-25 11:53:11 IST

    This is my database output for the date value(2003-04-25 11:53:11 IST). How to convet this string to Timestamp date value. Any one pl. help me

    BUT ... there is a public static Timestamp valueOf(String s) method in the Timestamp class that might help.
    http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Timestamp.html#valueOf(java.lang.String)

  • How to parse system date to return Date and in yyyy-MM-dd format?

    DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again it is converted into dfault format i.e. 21 Jan 00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and again to return date.
    Can anybody tell me how to do this?

    DateFormat dateFormat = new SimpleDateFormat
    ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again
    it is converted into dfault format i.e. 21 Jan
    00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and
    again to return date.
    Can anybody tell me how to do this?A Date object does not have a format, it represents a moment in time. You can use SimpleDateFormat to return a String representing that moment in time in many formats - this does not change the Date object to have that format (which it cannot since it does not contain a format).

  • How to parse URL Data into an NSString Array in iphone application

    Hi Every one
    I am newbie to iphone programming. I am having problem with reading and displaying the data into the table view. My application has to be designed like this. There is a csv file in the server machine and I have to access that URL line by line. Each line consists of 8 comma separated values. Consider each line has first name, second name and so on. I have to parse the data with comma and a newline and store them in an array of first name, second name array an so on. The next thing is I have to set first name second name combined and must be displayed in the UITableView. Can anyone provide me with an example of how to do it? I know I am asking the solution but I encountered a problem in connection methods separately and parsing simultaneously. You help is much appreciated.
    Thanks

    What does that have to do with a URL?
    The only thing that doesn't sound good is "array of first name" and "second name array". For each row, extract all the field and store them in an NSDictionary. Add a derived field consisting of first name concatenated with last name. That will be easy to display in a table.

  • How to Parse XML data directly from context variables in webdynpro

    Hello,
       I have two requirements:
    1) I have a context variable which has string value.
       I want to write the this value into a flat file.
       How do I do this in WebDynpro.
       Any sample code for this.
    2) In Webdynpro, I want to parse and process the XML data directly from a string context variable which
       has the value in XML format.
       How do I achieve this. Any pointers or sample codes for this.
    Thanks and Regards,
    Anupama.

    Anupama,
    Here is some link which talks about unpacking xml and converting to HTML.
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/eb/3dfb402eb5f76fe10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/eb/3dfb402eb5f76fe10000000a1550b0/content.htm</a>
    I have done something like this in portal development and not in webdynpro.But in principle it should work very where.

  • How to parse my datas into decimals

    Hi all, i've been trying to convert my data from exponential form into decimal how should i go about doing it?
    eventually, i will want to average out the data points(current) i got into a single value. Is there a better way to do so instead changing them into decimal form and try to average them again? Perhaps just do some formulas and get the final average value?
    I'm using LV 7.1. attached is the program i've done.
    thanks in advance
    Rgds,
    Linda
    Attachments:
    1.1.vi ‏104 KB

    Hi Linda,
    I attached an example of using 'Scan from String' to convert your string to an array of numbers...
    To do the formatting of numbers you should use 'Format into string' or set the formatting properties of your numeric indicators accordingly!
    (There's a huge page in the online-help on formatting codes :-)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    Convert_SFS_71.vi ‏22 KB

  • How to parse/reformat data from catchall()'s ora:getFaultAsString()

    Hi,
    I would like to translate the ora:getFaultAsString() data that is available in a catchall() block into XML so it can be
    included in the Fault response message that I send back to the WS client in a client-friendly format.
    In other words, rather than returning the original fault data as an unstructured string element:
    com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.oracle.com/bpel/extension}assertFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} parts: {{ summary=<summary xmlns:def="http://www.w3.org/2001/XMLSchema" xsi:type="def:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Quote not found.</summary> ,detail=<detail xmlns:def="http://www.w3.org/2001/XMLSchema" xsi:type="def:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">No data found for quote id: 0 quote number: 1</detail> ,code=<code xmlns:def="http://www.w3.org/2001/XMLSchema" xsi:type="def:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">001</code>}
    I want to return the data available in that string in structured XML format within my response document. What I
    would like to generate from the above string is something like this:
    <faultAsString>
    <summary>Quote not found.</summary>
    <detail>No data found for quote id: 0 quote number: 1</detail>
    <code>001</code>
    </faultAsString>
    Is there a built-in way to do this? Not finding one myself, I tried using ora:parseEscapedXML(),
    but since ora:getFaultAsString() does not return pure XML, the parse function does not seem able to
    parse the string. I also was unsure of the XML object type that could be used to assign the returning
    object from parseEscapedXML() into if that is the correct approach.
    Any help is appreciated. Thanks!

    Here is the bpel I'm using in my catchAll() to try to manage the error string as described above. It does not work for me:
    <variable name="gRuntimeFault" messageType="bpelx:RuntimeFaultMessage"/>
    <assign name="AssignRutimeFaultMessage">
    <copy>
    <from expression="ora:parseEscapedXML(ora:getFaultAsString())"/>
    <to variable="gRuntimeFault"/>
    </copy>
    </assign>
    When I run my WS I get this error in response:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault><faultcode>env:Server</faultcode><faultstring>XPath expression failed to execute.
    An error occurs while processing the XPath expression; the expression is ora:parseEscapedXML(ora:getFaultAsString()).
    The XPath expression failed to execute; the reason was: Start of root element expected..
    Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
    </faultstring><faultactor/><detail><exception/></detail></env:Fault></env:Body></env:Envelope>

  • IN ODATA, How to pass Timestamp data using POST method

    Dear all
    I am trying to insert a record into a HANA column store table using ODATA service.
    POST URL
    http://hanadrp.sial.com:8000/sial/sapnext/generic/odata/uidatetime.xsodata/UIDateTime
    Message one
      "IDTXT" : "1",
      "IDDATETIME" : "2014-09-19 10:20:10"
    Message Two
      "IDTXT" : "1",
      "IDDATETIME" : "/TO_TIMESTAMP(CURRENT_TIMESTAMP)/"
    Both give me this message
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <error
        xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
        <code/>
        <message xml:lang="en-US">Syntax error at position 0.</message>
    </error>
    The table here has only two columns and the IDDATETIME is a column of time TIMESTAMP
    Please advice

    Thanks Shreyansh to take time to reply
    Here below is the preview of the message from the POSTMAN preview button
    I really am not sure what is the X-CSRF token?
    POST /sial/sapnext/generic/odata/uidatetime.xsodata/UIDateTime HTTP/1.1
    Host: hanadrp.sial.com:8000
    Authorization: Basic YXJhbWFjaGE6U3JpcmFtNjY=
    Content-Type: application/json;charset=utf-8
    Cache-Control: no-cache
    { "IDTXT" : "1", "IDDATETIME" : "2014-09-01T00:00:00" }

  • How to parse this textfile

    I have a plan textfiel that i'm able to read but i can't parse the date and numbers in the text file.
    text content: [ 2007.10.19 11:53:42 ] (test) <color=0xffbbbb00>Your item, costs 598.0 euro.
    i suppose i can use substring/tokenizer but my knowledge in the tokenizer is limited.
    Does anyone know how to parse the date and costs so i can show the total costs for an item?

    mkoryak wrote:
    import java.util.regex.*;
    holy regex, batman! I definitely have to devote more time to regex. My mere mortal solution to some of the extractions went along these lines:
        private Color getColor(String text)
            Color c = null;
            String[] strArr = text.split("[<>]"); 
            // the forum mangles this  :( 
            // it should have angle brackets inside of square brackets. 
            String colorStr = strArr[1];
            colorStr = colorStr.substring(colorStr.indexOf("=") + 3);
            int[] colorInts = new int[4];
            for (int i = 0; i < colorInts.length; i++)
                String colorSubStr = colorStr.substring(2 * i, 2 * i + 2);
                colorInts[i] = Integer.parseInt(colorSubStr, 16);
            c = new Color(colorInts[0], colorInts[1], colorInts[2], colorInts[3]);
            return c;
        private Date getDate(String text)
            Date d = null;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
            String[] dateStrArr = text.split("[\\[\\]]");
            String dateStr = dateStrArr[1].trim();
            try
                    d = sdf.parse(dateStr);
            catch (ParseException e)
                e.printStackTrace();
            return d;
        }I will definitely study your code mkoryak, thanks.
    Edited by: petes1234 on Oct 24, 2007 10:09 AM

  • Timestamp data from OracleDataReader

    Hi. I have an OracleDataReader that has a TIMESTAMP as one of it's fields. What is the correct way to preserve the contents of this field (including fractional element) in a .NET DateTime object?
    Thanks
    KH

    Thanks Neeraj. However I was hoping to build classes that are agnostic of the provider (ie. use only native .NET types) once I have got the data out of the database - I cannot assume that the Oracle dlls have been installed on the machine that is ultimately consuming my classes.
    Any chance of a sample that shows how to get TIMESTAMP data to/from a DateTime object? DateTime goes down to tick (nanosecond) resolution so this should be possible so long as TIMESTAMP(6) is used.
    Many thanks
    Kevin

  • How to parse WPP format timestamps ?

    hi,
    Trying to use messageanalyzer for our custom log files.  We log the timestamp in the same format as WPP traces do (for legacy tools).
    e.g:
    06/03/2014-16:10:57.854
    How do I indicate in my config that the timestamp is in this format  ? As it stands if I set IsTimeStamp=true, analyzer fails to parse the field as a datetime.

    The format for Timestamp is pretty strict.  But you can parse the data using a syntax statement that extracts the date/time from the current string. 
    In this example, the date is split in two.  For your example, you could just parse the same string twice for each part.  Then a property, SCCMtsDateTime, sets the IsTimeStamp aspect and takes a Base message as the type.  If you derive your
    message from that base type, as in the example at the end.
    // Base type for all messages
    message BaseTimeStamp : LogEntry
     string Time;
     string Date;
    // Syntax creates a type based on an regex expression
    // time="17:24:35.005+300" date="07-08-2013"
    syntax CustomDateTimeFormat = month:regex{[0-9][0-9]} "-" day:regex{[0-9][0-9]} "-" year:regex{[0-9]+} " " hours:regex{[0-9][0-9]} ":" minutes:regex{[0-9][0-9]} ":" seconds:regex{[0-9][0-9]} "." fract:regex{[0-9]+} "+" tz:regex{[0-9]+}
            => ToDateTime(year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "." + fract + "+" + tz);
    // Property to return date type given a message of type BaseNetLogon.  Aspects for IsTimestamp allow you to replace the timestamp value.
    DateTime get SCCMtsDateTime(this BaseTimeStamp msg) with EntryFieldInfo {IsTimestamp = true, IsLocalTime = false }
     //optional DateTime theDateTime = CustomDateTimeFormat(msg.Date + " " + msg.Time);
     optional DateTime theDateTime = (msg.Date + " " + msg.Time).ToDateTime();
        if(theDateTime == nothing)
      return CustomDateTimeFormat("01/07/1968 12:34:56.987+500") as DateTime;
        else
      return theDateTime as DateTime;
    message SCCMLine with
     EntryInfo {
      Regex = @"^<!\[LOG\[(?<Message>.*)\]LOG]!><time=""(?<Time>.{16})"" date=""(?<Date>.{10})""\scomponent=""(?<Component>.*)""\scontext=""(?<Context>.*)""\stype=""(?<Type>.*)""\sthread=""(?<ThreadId>.*)""\sfile=""(?<File>.*):(?<LineNumber>.+)"">"//,
    Tag = "]LOG]"
     : LogEntry
     string Time;
     string Date;
    Hopefully this helps,
    Paul

  • How to parse string to date with defualt format?

    is there any possibilities to parse a string to date if we don't specify the format in SDF?
    In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?

    jwenting wrote:
    Tolls wrote:
    ColinAtWork wrote:
    SumantK wrote:
    In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?Why don't you store the date in the database as a DATE datatype then you can format anyway you like??Because some people seem to fear DATEs and prefer the supposed comforts of a VARCHAR2...after all, who knows what murky goings on occur with a DATE, but at least a VARCHAR2 is readable, or something like that anyway.Just because some people don't know how to work with DATE fields (which is the real reason for their "fear" doesn't mean you shouldn't use them.
    They're the appopriate solution, so use it.Often but not always true.
    For example neither MS SQL Server nor Oracle timestamp types will store the resolution capable with the Java Date type. So if one wants to maintain all of that resolution one requires either a varchar or two columns.
    And although I haven't been able to confirm it (recently at least) at one time one of the Oracle drivers had a bug that a timestamp would wipe out following columns. For that one either one was left with having only a single timestamp as the last column or using a varchar.

Maybe you are looking for

  • Installation problem of Oracle 9iAS rel2 on redhat advanced server 2.1

    Hi, I am trying to install Oracle 9ias Rel2 on redhat advanced server 2.1 Following instructions i downloaded and installed the binutils patch binutils-2.11.90.0.8-13.i386.rpm I have set ORACLE_HOME appropriately and created a new user oracle. During

  • HP Laserjet 100 color MFP M175 PCL6

    My printer worked fine connecting to the wireless network at home.  We just moved to a new State and have AT&T Uverse and their modem and router.  Cannot get the printer to connect to the router.  Tried everything I can think of including installing

  • Help with Decode/Case

    Hello All, Can I use decode/case function within a decode function? {code} SELECT TO_CHAR (           EDMS_STRAGG_WC (              DISTINCT DECODE (                          eqs.attrib_code,                          'PRODUCT_AUTHORIZATION',    'Auth

  • No further GRN - scenario

    Hi Experts, I want to "no GRN" for a line item in PO but invoice should be posted. I dont want to make this setting at vendor level but at PO order level. I tried to enable "no further GR required", so it doesnt expect GRN but when I post the invoice

  • Where get Messaging Server 6.3-2.01(64bit) for cluster 3.1Agent(SUNWscims)

    I'have Sun Java(tm) System Messaging Server 6.3-0.15 for Sun Cluster 3.1 Now I Successed upgrage to Messaging Server 6.3-2.01 (built Jun 13 2007; 64bit) But I Can't create Messaging Server 6.3 Server HA Resource I suspect SUNWscims of cluster3.1 does