Re: Getting Date Difference in Java.



In article <vOGdndR8vqDL6ubfRVn-hw@xxxxxxxxxxx>, "Lucky" <jlnarayana@xxxxxxxxxxx> wrote:
>Hi
>In oracle, if I need to get the sysdate, I would do some thing like this
> select sysdate from dual;
>And if I need , the difference between sysdate and a specific date ,say
>"pdate" ,I would do,
> select sysdate - pdate from dual
>This would give me the difference in days ,so for ex
> select sysdate -to_date('01-JAN-2005') from dual
>would give me 125 as the number of days.
>---
>Now what I want to know is that in java how do I this. I tried to play
>around with the Date and Calendar objects.
>These objects are giving me individual feilds like day,month and year etc,
>but not date as a whole. So my question is
>
>1. How do I get the date in java in a specific format (in any format I
>choose). What is the best object for this.

SimpleDateFormat

>2. How do I get the difference in 2 dates, which should give me in number of
>days.

Take a look at the GregorianCalendar class
>
>Your quick responses are appreciated.
>
>Thanks,
>
>PS. By the way how do we do the same in JavaScript.
>
>
>
.



Relevant Pages

  • Re: Getting Date Difference in Java.
    ... >get number of days divide it by 86400000L. ... >>> In oracle, if I need to get the sysdate, I would do some thing like this ... How do I get the date in java in a specific format (in any format I ...
    (comp.lang.java.programmer)
  • Getting Date Difference in Java.
    ... In oracle, if I need to get the sysdate, I would do some thing like this ... select sysdate - pdate from dual ... How do I get the date in java in a specific format (in any format I ...
    (comp.lang.java.databases)
  • Getting Date Difference in Java.
    ... In oracle, if I need to get the sysdate, I would do some thing like this ... select sysdate - pdate from dual ... How do I get the date in java in a specific format (in any format I ...
    (comp.lang.java.developer)
  • Getting Date Difference in Java.
    ... In oracle, if I need to get the sysdate, I would do some thing like this ... select sysdate - pdate from dual ... How do I get the date in java in a specific format (in any format I ...
    (comp.lang.java.programmer)
  • Getting Date Difference in Java.
    ... In oracle, if I need to get the sysdate, I would do some thing like this ... select sysdate - pdate from dual ... How do I get the date in java in a specific format (in any format I ...
    (comp.lang.java.help)