Converting Date.toString() back to a Date object for compare

I know this is beating a dead horse to death but I have wasted a whole day trying to get this to work. Here is the problem.
I need to convert a Date().toString (format returned: Dec 19, 2006 3:39:58 PM EST) back to a Date object. What I am doing is writting this string a text file and then revisiting it to compare later to a current Date object to find the difference in the two stamps in milliseconds.
J2SE 1.4.2 being used
Date date = new Date();
String newDateStr = log[1].trim(); // entry from log file
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date logDate = dateFormat.parse(newDateStr);
// get difference between the two
long timeSpan = date.getTime() - logDate.getTime();
if(timeSpan > 60000){
    // TO DO
}So should I look at a different approach at either:
A) Storing the date/time stamp in the text file
B) The conversion back to Date object is wrong
Really appreciate any insight on this.
Thanks
JLW
Message was edited by:
jlwestsr

Then my friend you are in the same status as Tim.:o)
I don't know as much as him and I don't care to write
an elaborate reply most of the time. :D
Merry ChristmasSame to you.I don't pretend to know that much, but When I see something I do know, I tend to give examples.
Most probably that is because at the present time I am in a situation where most of my time is spent waiting for a call from the customer, and the app I am supporting works so well that those calls are few and far between. Lucky for me, they pay me for sitting around and answering questions on a forum.
At least it is a java forum, where I can justly claim that I am improving my knowledge of java.
~Tim

Similar Messages

  • BSP Exception: Missing reference when converting data object ZZxx

    Hi there,
    I have created these new Z fields and tried to include them in a field group. These fields did appear, but they are highlighted with a red box, with the above text in the tool tip.
    Does anyone know what it means??
    Thanks

    I believe they were generated by EEWB - or could've been added manually to the CRMD_CUSTOMER_H. This error only occurs on the Currency fields...something to do with reference field but I just can't find what is wrong with this. I searched up SAP notes and found the following the closest match: -
    <b>Symptom</b>
    when trying to scroll down in the result list in the F4 for the Ibase the error error "BSP exception : Missing reference when converting data object amount.  Correct the entry" occurs.
    <b>Other terms</b>
    CRMT_BSP_IBASE_TREE_NF, data object amount
    <b>Reason and Prerequisites</b>
    This happens due to inconsistancy in structure
    <b>Solution</b>
    Please follow the below steps manually.
    1. Go to tx:SE11
    2. Select data type "CRMT_BSP_IBASE_TREE_NF" in change mode
    3. Select component AMOUNT in 'Components' tab
    4. Go to "Currency/quantity fields" tab
    5. Replace 'Reference table' entry from 'CRMT_BSP_IBASE_DETAIL'
       to 'CRMT_BSP_IBASE_TREE_NF'
    6. Save and activate

  • Error while getting data objects for instance

    Hello Expert,
    I am getting some weird error - whenever there is a new process is triggered and I check context Data, I get following error -
    "Error while getting data objects for instance processinstanceid"
    Thanks is advance
    Priya

    Hi Priya,
    this is a known issue in the xml processing of the Java Virtual Machine. Please refer to the SAP Note for this issue: 1949395
    This should solve your issue.
    Best regards,
    Stefan

  • Convert Date Object to Calendar object

    Hi,
    I have a Date field in my webdynpro application, I need to to read this from my current context and convert the same to a Calendar field and pass it to my model.
    Calendar date = CalendarConverter.parseDate(req_date.toString());
    The above code gives me a null pointer exception.
    Can anyone suggest me the right way of converting a Date object to Calendar object?
    Ashwini.

    Ashwini,
    try to use the following code snippet:
    // get calendar and set your date object
    Calendar c = Calendar.getInstance();
    c.setTime( <YOUR_DATE_OBJECT> );
    // to manipulate the fields use this
    c.set(Calendar.MONTH, 1);
    // to manipulate retrieve a fields use this
    c.get(Calendar.MONTH);
    Hope that helps you.
    Sebastian Voss

  • How to convert date object format to new?

    Hi,
    I have data object and I want to convert it to this format.
    DD MMM YYYY
    eg: 23 MAR 2003
    I am looking for exact line of code please.
    Thanks,
    Kavans.

    You should check out the Javadoc for java.text.DateFormat and java.text.SimpleDateFormat.
    As for the exact line of code then this would be close:
    Date date = ...; // wherever your date comes from
    DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
    String dateAsString = dateFormat.format(date);Remember to check out those Javadocs, though, 'cos they'll tell you the various formatting options available.
    Hope this helps.

  • Converting Date Object

    plz help me,
    I want Date in simple format as dd/mm/yyyy.
    I am retrieving date from database (oracle) and now i want to convert that date to simple "dd/mm/yyyy"
    e.g : date_from_oracle=Wed Feb 01 09:10:59 GMT+05:30 1950
    converted_date=1/2/1950 (and this should be date object and not String)
    System.out.println("converted date:" + converted_date);
    above line should print : converted date:1/2/1950
    if u r clear with my question then plz help me
    Thanks

    No my problem is that i am developping J2EE
    application where i am getting date values in EJB
    that i want to display on JSP page.
    For this i am using struts and passing collection of
    data values to it.That shouldn't make the solution any different.
    My oracle date format is 01-Jan-2005 (dd/mmm/yyyy).
    In my ejb there is one attribute named "date_display"
    of type Date. In Struts Action i retrieved collection
    of all dates from database that i want to display on
    JSP page as it is without any parsing. Then you should not bother about the format.
    If i iterate above collection in JSP page it displays
    date along with GMT and Time format. I dont want
    this. I want to set "date_display" in such a way that
    it should contain date values but in simple format as
    "1-Jan-2005 OR 1/1/2005". Important thing is that the
    Setter Method for date_display accepts parameter of
    Date type. So even SimpleDateFormat also not useful.If it is not useful, write your own method. <_<
    please help me out as i am stuck there.
    System.out.println(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));

  • Parse Date object for AM/PM

    how do we parse whether it is AM /PM from Date() object?

    You asked this question yesterday already with the same degree of vagueness.
    Please return to your thread from yesterday and continue posting vague dribblings as they occur to you there http://forum.java.sun.com/thread.jspa?threadID=5198538

  • How to Convert Date Object at Universe Level with out Timestamp

    Hi,
    I have a Object  called "PCREGISTERDATE" at universe where the data type is date .but the dates are coming in the following format:9/26/2007 9:48:40 PM but i want to show the date as with out time stamp.
    how can i create a object by at universelevel which shoul show only date with out Time Stamp.
    please help me on this ASAP.
    Thanks & Regards,
    Kumar

    Please try below date fucntion:
    select convert(varchar(10),getdate(),101)  - this is for sybase
    syntex will change based on your source database.
    Thanks
    Ponnarasu .K

  • How to convert  a date object to gregorianCalendar

    hi,
    I need to convert Date object to a gregorian calendar object. Can anyone tell me how to do that?
    thanx

    GregorianCalendar gc = new GregorianCalendar();
    gc.setGregorianChange(new Date(Long.MIN_VALUE))
    gc.setTime(new Date());

  • Date object to RichInputDate

    Hello,
    How can i convert Date object to RichInputDate
    Vice versa was possible bt i want it other way round

    Converting RichInputDate to specific format
    https://kr.forums.oracle.com/forums/thread.jspa?threadID=2242338

  • How to set Timezone in a date object

    Hi,
    I need to write a method setTimeZone(Date d,TimeZone t) which should take a Java.util.Date and a Timezone object and set the time zone to the date object.
    for example...
    Date d=new Date();
    TimeZone tz=TimeZone.getTimeZone("PST");
    //should print the timezone as EDT because the current system timezone is EDT
    System.out.println(d);
    setTimeZone(d,tz);
    //should print the timezone as PST
    System.out.println(d);
    public void setTimeZone(Date d,TimeZone tz){
    Calendar c=Calendar.getInstance(tz);
    c.setTime(d);
    c.setTimeZone(tz);
    d=c.getTime();
    System.out.println("Timezone in calendar is "+c.getTimeZone().getDisplayName());
    But today is still showing up EDT timezone and Timezone in calendar is shown as PST.The new timzone is not aplied to date object @ d=c.getTime();
    statement.
    Could any one please help me...
    Edited by: mchepuri on Apr 10, 2009 7:27 PM
    Edited by: mchepuri on Apr 10, 2009 7:29 PM

    Dates don't have any concept of time zones. Think of a Date as a wrapper for a long.
    Use SimpleDateFormat. Read the javadocs for some useful methods.

  • Import Data object using web service adapter

    Hello experts,
    In DOE, theres a way to import Data Object from a wsdl using webservice adapter. We got to know that there are some guidelines(constraints) on the operations provided in the wsdl to be able to use webservice adapter. Could you please give a sample wsdl which can be used to import Data object for our reference?
    Thanks in Advance,
    Srilatha

    Hi Srilatha,
    SAP Netweaver 7.3 is not yet released to customers.  Once, this happens we will post sufficient documentation related to the Import of Data Objects through WSDLs.  In case you require the information urgently, kindly get in touch directly with the colleagues from DOE Mobile team.
    Best Regards,
    Kranti

  • How to move multiple decision tables values into results data object

    Hi Carsten and other experts,
    I am building a BRF+ function and have a question, I would probably try to give an example to better explain the issue.
    1. Function Signature
    Context elements:  C1, C2, C3
    2. Ruleset has two decision tables DT1 and DT2.
    DT1 take C1, C2, C3 as inputs to provide C4 and C5.
    DT2 takes C5 takes as inputs to provide C6.
    What should be results data object for function to get C4,C5 and C6 as Function Output parameters?
    I have tried different combination of structures and table and couldn't figure out how it behaves.
    Thank you
    Kris

    The function gets a result structure with components C4, C5, C6.
    In a ruleset assigned to the function you have a rules that calls the two decision tables DT1/2.
    Create a structure for DT1 with C4 and C5 as components. Make the structure the result of your decision table.
    DT2 has C6 as a result.

  • Loads to Master data object

    If I have created selection packages to load to a master data object for example:
    1. Load to 0MAT_PLANT
    2. Five packages created filtered by plant range
    If I kick off the first package do I need this load to finish before the second package can load into the object i.e. 0MAT_PLANT is locked by the first package or can I load packages in parallel to a master data object?  If so how? Thanks

    Thanks for that, have carried that out.  I have observed the following would be grateful if someone could confirm
    1. Have a package running 2+ million lines
    2. Kick off a package with a few hundred thousand lines after the first package, will complete before first package
    3. Get an error since the extract completes in R3.  However cannot load to the object since it is locked by the first
    4.  Message below:
    User BWR3REMOTE is preventing you from loading master data for
    characteristic 0MAT_PLANT . The lock was set by the master data loading
    process with the request number (DataPackage number)
    REQU_46MIUD73IBHYLLD9KZCAX4P47(000226) on 20070729,171630(711753) .

  • Customizing JTree data rendering for Dates

    I have a JTree that has different data types in each column that I'm sorting. I'd like to be able to control the String that appears in the table cell(s) based on the value in the model. I'm trying to make it so that if a Date is less than some predeterminded Date value that a custom string is output to the Table cell instead of the normal Date string.
    I thought a JTable took the toString() of the Date object for its value and that I could just subclass the java.util.Date object and override the toString() with a conditional. such as (toString() in my CustomDate subclass that extends java.util.Date):
    public String toString() {
        defaultDate = new java.util.Date();
        if (defaultDate.getTime()>this.getTime()){
            return "Date entered in the past";
        } else { //get the normal Date toString
            return new String(super.toString());
    }I'm not so much asking what is wrong with my code, but how to accomplish this task, the code is simply to show the direction I've taken. Am i close, or way out in left field?
    Thanks for any help guys!

    Zulfi100 needs a BrainCellRenderer.He is strangely disturbing yet amusing at the same time. It worries me that he is going to use the skills he learns here to teach.

Maybe you are looking for

  • My mid 2010 MacBook Pro loses network connectivity

    I have four mac computers running on our home network.  My mid 2010 MacBook Pro has become notorious for losing network connectivity with the other computers.  It maintains it's internet connectivity consistently, but it's ability to see and connect

  • Self assigned IP address bull

    Ok, I suffer from the self assigned ip nightmare that so many face! But still there is no word from your official site on how to fix this! I gave up using my PC that was assigned to me at my work place. I brought my mac and since then it has been not

  • 2 Column Page Layout

    I'm wondering if there is any way to have two-columns set up in one section of a document and then one column in another. I'm working on taking notes for my biology class and am trying to separate the vocabulary words from the notes themselves, and w

  • Replace ' with ' in my data using pl/sql

    I want to replace all occurrence of special characters like ' with ' in my data using pl/sql. How can I achieve this?

  • ZF (trad. chinese) language Issue

    Hi After Installation Traditional Chinese(ZF) language, and when I login to SAPGUI with ZF option, I notice that the SAP menu language with inappropriate characters like square box, ?, etc.. Is there any step which I need to execute as post language