Why there is two Date Class

There are two Date Class
One in Pacakge java.util.Date
another in Package java.sql.Date
What the difference between these two class and when to use whom.

The documentation explains the difference:
http://java.sun.com/j2se/1.4.2/docs/api/index.html
/Kaj

Similar Messages

  • Why there r two functions (do post & do get)

    why there r two functions doget() & dopost() while any code can run in any of them and give me the same result.
    sure, here is difference but what this difference ?
    thnx in advance

    thnx shudha
    this thread is very good, i pasted it here to clear the vision for otheres too:
    There are two points between GET and POST
    01) Amount of information u can get.
    02) Post is secure for getting Passwords and credit cards numbers.
    GET puts the form values into the URL string. GET is limited to about 256 characters (usually a browser limitation) and creates really ugly URLs.
    POST allows you to have extremely dense forms and pass that to the server without clutter or limitation in size. e.g. you obviously can't send a file from the client to the server via GET.
    Below lines are from http://www.microsoft.com/windows2000/techinfo/reskit/en/iisbook/c06_the_difference_between_get_and_post.htm
    QUOTE
    The GET method, which was used in the example earlier, appends name/value pairs to the URL. Unfortunately, the length of a URL is limited, so this method only works if there are only a few parameters. The URL could be truncated if the form uses a large number of parameters, or if the parameters contain large amounts of data. Also, parameters passed on the URL are visible in the address field of the browser�not the best place for a password to be displayed.
    The alternative to the GET method is the POST method. This method packages the name/value pairs inside the body of the HTTP request, which makes for a cleaner URL and imposes no size limitations on the form�s output. It is also more secure.
    UNQUOTE
    Hope abv will help.

  • Why there are two IMG steps provided for Home Page configuration?

    Dear experts,
    I wonder why there are two IMG steps provided for configuring ESS home page.
    1. Cross Application Components --> Employee Self Service --> General Settings
    2. Personnel Management --> Employee Self-Service --> General Settings
    Both tables contents are also similar.
    Why SAP has provided same configuration steps in two areas?

    Your first one is wrong. It is under Cross App. Components but not in an ESS node....I am sure it is a typo on your part. Anyways......
    It's NOT two steps. It's just the same configuration in two places. It makes it easier to locate for instance if you are in ESS to just have it there. BUT the Homepage Framework is used elsewhere (MSS for example) as well as you can use it for whatever else you like (building an easier interface for other things) therefore, it has it's "true" place up as a "cross application component".
    This is very similar to say Benefits. If you look under the Benefits config area in the IMG, you will actually see a lot of ESS settings there that are the exact same ones you see under the ESS node too.
    Don't let it confuse you.

  • Why there are two init methods?

    I copied this code from netbeans for a JApplet.. and it has two init methods
    One is public void init() that calls another initComponents() method.
    And the initComponents() method has all the components defined in it, and it is private.
    I replaced private with public and changed initComponents to init, and then deleted all the init method, it worked that way.
    But why there two methods when you can put every thing in single init() method?
    The init() method has this code in it:
    public void init() {
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        initComponents();
            } catch (Exception ex) {
                ex.printStackTrace();
        }

    BDLH:
    WWJD? Probably code in Ruby, but I digress. No, he would define an abstract base for that boilerplate code:
    import java.awt.*;
    import java.lang.reflect.*;
    import javax.swing.*;
    public abstract class AbstractApplet extends JApplet {
         public void init() {
              try {
                   EventQueue.invokeAndWait(new Runnable() {
                        public void run() {
                             initComponents();
              } catch (InterruptedException ex) {
                   ex.printStackTrace();
              } catch (InvocationTargetException ex) {
                   ex.printStackTrace();
         protected abstract void initComponents();
         //ditto: start, stop, distroy
    }

  • Why there is a Color class in the LiveDocs?

    If the old color class was gone, why in the online documentation it is still standing?
    http://livedocs.adobe.com/flash/9.0_it/ActionScriptLangRefV3/fl/motion/Color.html
    What does this class do?

    it's not gone.
    it gives another way to control color by allowing tint and brightness settings.

  • Why there is no date and year next to time above while i am writing this?

    ????

    If you are talking about the time shown at the top middle of the screen then only the time is displayed. The date is not displayed. If you wish to suggest that the date be displayed as well tell Apple at http://www.apple.com/feedback/iphone.html

  • Data class is ambiguous

    hi i get the following error when i compile my code. it says that my Date class is ambihuous???
    icomm server\src\icommserver\admin.java:268: reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match..
    here is my code below:
    package icommserver;
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.text.*;
    //get todays date
                     GregorianCalendar thisday = new GregorianCalendar();
                     Date d1 = thisday.getTime();
                     DateFormat df = DateFormat.getDateInstance();
                     today = df.format(d1);

    Did you actually read the compiler's diagnostic? It says this:reference to Date is ambiguous, both class java.util.Date in java.util
    and class java.sql.Date in java.sql match..There are two Data classes in two different packages; when you define
    a Date object, which one do you want? You have to specify this Date
    object using its fully qualified name, i.e. it has to include its full package name.
    kind regards,
    Jos

  • Two problems with two different classes.

    im having two problems: i get nothing with the printConferences() method inside ReferenceBook class, the arraylist size is equal to zero. and my printSchoolsAndCopies() and schoolsAndCopiesToArray() methods which are inside TextBook class, give exceptions:
    Exception in thread "main" java.lang.ArrayStoreException at java.lang.System.arraycopy(Native Method) at java.util.ArrayList.toArray(ArrayList.java:304) at project3.TextBook.schoolsAndCopiesToArray(TextBook.java:64) at project3.TextBook.printSchoolsAndCopies(TextBook.java:74) at project3.BookTester.main(BookTester.java:27) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)
    all you need to read is TextBook and ReferenceBook class, but i added the tester and BookCatalog, which is an arraylist of books.
    here are my TextBook and ReferenceBook classes and the tester, there are two abstract classes Book and TechnicalBook, but i wont post them unless anybody needs them, i presume not.
    * TextBook.java
    * Created on April 19, 2007, 8:02 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    import java.util.*;
    * @author Kevin
    public class TextBook extends TechnicalBook{
        private ArrayList <String> schools;
        private ArrayList <Integer> numberCopiesForSchool;
        private String [][] schoolsAndCopies;
        public static final String TEXTBOOK = "Textbook";
        /** Creates a new instance of TextBook */
        public TextBook(String author, String title, int numberPages, int copiesSold,
                double price) {
            super(author, title, numberPages, copiesSold, price);
            schools = new ArrayList();
            numberCopiesForSchool = new ArrayList();
        public int getNumberCopiesForSchool(String school){
            Integer temp = null;
            for(int i = 0; i < schools.size();i++){
                if(schools.get(i).equals(school))
                   temp = numberCopiesForSchool.get(i);
            return temp;
        public void addSchool(String school){
            Integer one = new Integer(1);
            schools.add(school);
            // number of copies for the school is initially 1
            numberCopiesForSchool.add(one);  
        public int getNumberSchools(){
            int count = 0;
            for(int i = 0; i < schools.size(); i++){
                if(schools.get(i) != null)
                    count++;
            return count;
        public void addCopiesForSchool(String school, int copies) {
              for (int i = 0; i < schools.size(); i++) {
                        if (schools.get(i).equals(school))
                   numberCopiesForSchool.set(i, numberCopiesForSchool.get(i)
                                + (Integer) copies);
        private void schoolsAndCopiesToArray(ArrayList <String> a, ArrayList <Integer> b){
            String [] c = null;
            String [] d = null;
            c = (String[]) a.toArray(new String[a.size()]);
            d = (String[]) b.toArray(new String[b.size()]);
            String [] [] schoolsAndCopies = null;
            for(int i = 0; i < c.length;i++){
                for(int j = 0; j < d.length;j++){
                    schoolsAndCopies[i] = c;
                    schoolsAndCopies[j] = d;
        public void printSchoolsAndCopies(String title){
            schoolsAndCopiesToArray(schools, numberCopiesForSchool);
            System.out.println("---------------");
            System.out.println("Schools and copies sold to each school for " + this.title+ ".");
            System.out.println("Schools:\tCopies:");
            for(int i = 0; i < schoolsAndCopies.length;i++)
                for(int j = 0; j < schoolsAndCopies.length;j++)
    System.out.println(schoolsAndCopies [i] + "\t" +
    schoolsAndCopies[j]);
    public String getClassName(){
    return TEXTBOOK;
    // overrides TechnicalBook toString
    public String toString(){
    return "Author = " + author + ". Title = " + title + ". Number of Pages = " +
    numberPages + ". Copies Sold = " + copiesSold + ". Schools using " + title +
    ". Price = " + this.getPrice() + " = " + this.getNumberSchools() + ". ";
    * ReferenceBook.java
    * Created on April 19, 2007, 8:02 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    import java.util.*;
    * @author Kevin
    public class ReferenceBook extends TechnicalBook{
    private ArrayList <String> conferences;
    public static final String REFERENCE_BOOK = "Reference Book";
    //private int numberConferences;
    /** Creates a new instance of ReferenceBook */
    public ReferenceBook(String author, String title, int numberPages, int copiesSold,
    double price) {
    super(author, title, numberPages, copiesSold, price);
    conferences = new ArrayList();
    public String getConference(int a){
    for(int i = 0; i < conferences.size();i++)
    if(i == a)
    return conferences.get(i);
    return null;
    public void addConference(String conference){
    for(int i = 0; i < conferences.size();i++){
    conferences.add(conference);
    break;
    public void printConferences(){
    System.out.println("-------------");
    System.out.println("Conferences made for " + this.title + ".");
    for(int i = 0; i < conferences.size(); i++){
    System.out.println("["+(i + 1) +"]: "+ conferences.get(i));
    System.out.println(conferences.size());
    public String getClassName(){
    return REFERENCE_BOOK;
    public String toString(){
    return super.toString();
    * BookTester.java
    * Created on April 19, 2007, 8:02 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    * @author Kevin
    public class BookTester{
    /** Creates a new instance of BookTester */
    public static void main(String [] args){
    BookCatalog catalog = new BookCatalog("Library");
    TextBook java = new TextBook("John", "Java", 5, 20, 5.00);
    TextBook beans = new TextBook("Mike", "JavaBeans", 6, 21, 5.00);
    ReferenceBook ref = new ReferenceBook("Jones", "Standard Class Library", 6, 23, 5.00);
    ref.addConference("Meeting");
    ref.printConferences();
    beans.addSchool("UTSA");
    beans.printSchoolsAndCopies("c++");
    catalog.addBook(java);
    catalog.addBook(beans);
    catalog.printCatalog();
    my BookCatalog class is fine, and everything prints out with out using the listed methods that give trouble.
    * BookCatalog.java
    * Created on April 20, 2007, 4:42 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    import java.util.*;
    * @author Kevin
    public class BookCatalog {
        private String name;
        private ArrayList <Book> bookList;
        /** Creates a new instance of BookCatalog */
        public BookCatalog(String name) {
            this.name = name;
            bookList = new ArrayList <Book>();
        public String getCatalogName(){
            return name;
        public void addBook(Book b){
            bookList.add(b);
        public void printCatalog(){
            for(int i = 0; i < bookList.size(); i ++){
                System.out.println("[" + i + "]: " + bookList.get(i).getClassName() +
                       ": " + bookList.get(i).toString());
    }thanks in advance

    everything runs now, but it doesnt sort them. it prints them in the original order: here is the revised BookCatalog and Tester, also when making sortByTitle static it gives non static variable errors so i have no idea. Thanks for helping me fix the errors, i have no idea why it doesnt sort.
    * BookCatalog.java
    * Created on April 20, 2007, 4:42 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    import java.util.*;
    * @author Kevin
    public class BookCatalog {
        private String name;
        private ArrayList <Book> bookList;
        //private Book [] bookList2;
        /** Creates a new instance of BookCatalog */
        public BookCatalog(String name) {
            this.name = name;
            bookList = new ArrayList <Book>();
        public String getCatalogName(){
            return name;
        public void addBook(Book b){
            bookList.add(b);
            public void sortByTitle(ArrayList<Book> list){
          if (bookList.size() > 1)
            for (int index = 1; index < bookList.size(); index++)
               insertItemByTitle(bookList, index);
         private void insertItemByTitle(ArrayList <Book> bookList, int index) {
                Book key = bookList.get(index);
                int position = index;
                while (position > 0 && key.getTitle().compareTo(bookList.get(index).getTitle()) < 0)   {
                    bookList.set(position, bookList.get(position-1));// = bookList.set(position-1, key);
                   position--;
                bookList.set(position, key);
        public void printCatalog(){
            sortByTitle(bookList);
            Book [] bookList2 = (Book[])bookList.toArray(new Book[bookList.size()]);
            for(int i = 0; i < bookList2.length; i ++){
                System.out.println("[" + (i+1) + "]: " + bookList2.getClassName() +
    ": " + bookList2[i].toString());
    * BookTester.java
    * Created on April 19, 2007, 8:02 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package project3;
    * @author Kevin
    public class BookTester{
    /** Creates a new instance of BookTester */
    public static void main(String [] args){
    BookCatalog catalog = new BookCatalog("Library");
    TextBook java = new TextBook("John", "Java", 5, 20, 5.00);
    TextBook beans = new TextBook("Mike", "JavaBeans", 6, 21, 5.00);
    ReferenceBook ref = new ReferenceBook("Jones", "Standard Class Library", 6, 23, 5.00);
    ref.addConference("Meeting");
    ref.printConferences();
    beans.addSchool("UTSA");
    //beans.printSchoolsAndCopies("c++");
    catalog.addBook(ref);
    catalog.addBook(java);
    catalog.addBook(beans);
    catalog.printCatalog();

  • Logic at reporting level to compare two dates .

    Dear Friends,
    I have a scenario here , where i have a counter keyfigure in my DSO which has constant value 1 . there is two dates : Stock issue date & stock receipt date .  At the reporting level , in selection screen there is an input on stock receipt date . Now i want to show key figure counter for which stock issue date lies between the stock receipt date which the user enters .
    Kindly suggest on this matter .
    Thanks & regards,
    Ashutosh Singh

    1. Create a customer exit variable on Stock issue date. Pass on the value the user enters through exit to this variable.
    2. Create a New formula with the counter keyfigure and restrict it based on the customr exit variable.
    This will work correctly if Stock issue date and stock receipt date are not displayed in the report.
    If it is displayed, then if the stock issue date lies between the stock receipt date it will have the value as 1 else 0.
    Hope this helps.
    rgds, Ghuru

  • Formula for compare two date fields

    Please help me,
    There are two date fields in DSO , I want to create a key figure by Query Designer, the condition as blow
    Count ( If field DateA > field DateB = 1 else 0 ).

    http://www.sd-solutions.com/SAP-HCM-BW-Replacement-Path-Variables.html
    create 2 formula varaibles like above and comapre it

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • Duration between two date

    If there is two date and I want to know how many days, mouths and years between this two date (the duration between them).
    example
    the first date 15/01/2000
    the second date 12/02/1980
    the answer must be 19 years ,11 mouths and 3 days.
    how can I write code of this describtion?
    note:
    don't forgot every four years have a year
    with 366 days not 365 days.

    I know that the differant between date is number of days but I can say the age of person to the date 15/1/2000 is for example 19 years, 11 mouths and 3 days if this person born in 12/2/1980.and I ask about this problem.

  • Centro Hotsync problem: two Date Books, second never finishes syncing

    I have a Centro. It worked fine syncing for many months using the USB cable. For some reason, now it won't synchronize. All the information in Palm Desktop on my computer disappeared -- I only have my calendar on the phone now. When I try to sync, the HotSync Progress box appears on my computer, and if I show the details, it gives me the following, where there are two Date Books and the second one never completes:
    Package Installer -- done
    Install -- done
    Install Service Templates -- done
    Install To Card -- done
    HotSync Exchange -- done
    Date Book -- done
    Date Book -- synchronizing
    Address Book
    Address Book
    To Do List
    To Do List
    Memo Pad
    Memo Pad
    Addit
    Media
    As you can see, several items from Date Book on are doubled, and the second Date Book gets stuck in perpetual synchronizing.
    I haven't found any answer for this in searching the forums. I tried uninstalling and reinstalling Palm Desktop. I followed advice on Palm's troubleshooting page to rename my username on Palm Desktop and to delete my username from the phone. None of it made any difference. 
    Thanks for your help.
    Post relates to: Centro (AT&T)

    check the hotsync log for the 2nd user (2nd centro that froze).
    try see if you can find any significant error message or codes.
    also try to attempt syncing the 2nd centro and this time change the action of the datebook/calendar to handheld overwrites the desktop.
    that if your desktop is good to be overwritten.
    it is very unusual to behave this way where both of the centros have 2 different user ID's and both are syncing to palm desktop.
    Post relates to: Treo 680 (Unlocked GSM)

  • Generate linear dates betwen two dates

    Hi,
    There are two dates as input. need to generate series of dates between those dates. Dates must appear in column wise
    please suggest how to write the query on that.
    Eg: If we enter two dates as start date 1-JAN-2011 and end date as 5-JAN-2010
    It must generate a linear date as 1-JAN-2011 2-JAN-2011 3-JAN-2011 4-JAN-2011 5-JAN-2011
    date must appear as column wise. P|lease let me know
    Thanks
    Sudhir

    SQL> -- generating sample data:
    SQL> with t as (
      2  select to_date('1-JAN-2011', 'dd-mon-yyyy') start_date
      3  ,      to_date('5-JAN-2011', 'dd-mon-yyyy') end_date
      4  from   dual
      5  )
      6  --
      7  -- actual query:
      8  --
      9  select max(decode(max(lvl), 1, dt)) dt1
    10  ,      max(decode(max(lvl), 2, dt)) dt2
    11  ,      max(decode(max(lvl), 3, dt)) dt3
    12  ,      max(decode(max(lvl), 4, dt)) dt4
    13  ,      max(decode(max(lvl), 5, dt)) dt5
    14  from ( select start_date+level-1 dt
    15         ,      level lvl
    16         from   t
    17         connect by level <= end_date-start_date+1
    18       )
    19  group by dt;
    DT1                 DT2                 DT3                 DT4                 DT5
    01-01-2011 00:00:00 02-01-2011 00:00:00 03-01-2011 00:00:00 04-01-2011 00:00:00 05-01-2011 00:00:00
    1 row selected.
    SQL> -- generating sample data:
    SQL> with t as (
      2  select to_date('1-JAN-2011', 'dd-mon-yyyy') start_date
      3  ,      to_date('5-JAN-2011', 'dd-mon-yyyy') end_date
      4  from   dual
      5  )
      6  --
      7  -- actual query:
      8  --
      9  select max(decode(max(lvl), 1, dt)) dt1
    10  ,      max(decode(max(lvl), 2, dt)) dt2
    11  ,      max(decode(max(lvl), 3, dt)) dt3
    12  ,      max(decode(max(lvl), 4, dt)) dt4
    13  ,      max(decode(max(lvl), 5, dt)) dt5
    14  from ( select start_date+level-1 dt
    15         ,      level lvl
    16         from   t
    17         connect by level <= end_date-start_date+1
    18       )
    19  where to_char(dt, 'dy', 'nls_date_language=american') not in ('sat', 'sun')
    20  group by dt;
    DT1                 DT2                 DT3                 DT4                 DT5
                                            03-01-2011 00:00:00 04-01-2011 00:00:00 05-01-2011 00:00:00
    1 row selected.

  • Is there a Java utility class to help with data management in a desktop UI?

    Is there a Java utility class to help with data management in a desktop UI?
    I am writing a UI to configure a network device that will be connected to the serial port of the computer while it is being configured. There is no web server or database for my application. The UI has a large number of fields (50+) spread across 16 tabs. I will write the UI in Java FX. It should run inside the browser when launched, and issue commands to the network device through the serial port. A UI has several input fields spread across tabs and one single Submit button. If a field is edited, and the submit button clicked, it issues a command and sends the new datum to the device, retrieves current value and any errors. so if input field has bad data, it is indicated for example, the field has a red border.
    Is there a standard design pattern or Java utility class to accomplish the frequently encountered, 'generic' parts of this scenario? lazy loading, submitting only what fields changed, displaying what fields have errors etc. (I dont want to reinvent the wheel if it is already there). Otherwise I can write such a class and share it back here if it is useful.
    someone recommended JGoodies Bindings for Swing - will this work well and in FX?

    Many thanks for the reply.
    In the servlet create an Arraylist and in th efor
    loop put the insances of the csqabean in this
    ArrayList. Exit the for loop and then add the
    ArrayList as an attribute to the session.I am making the use of Vector and did the same thing as u mentioned.I am using scriplets...
    >
    In the jsp retrieve the array list from the session
    and in a for loop step through the ArrayList
    retrieving each CourseSectionQABean and displaying.
    You can do this in a scriptlet but should also check
    out the jstl tags.I am able to remove this problem.Thanks again for the suggestion.
    AS

Maybe you are looking for

  • How to setup Flex SDK with latest AIR SDK?

    Now the latest AIRSDK web page has a small link at the bottom for Flex users and it states that Flex users should take the SDK version without the compiler. BUT.... the http://helpx.adobe.com/flash-builder/kb/overlay-air-sdk-flash-builder.html page s

  • PI : Idoc to JDBC scenario : repeating segments mapping issue

    Experts Please help. Question reg. mapping for ECC idoc to JDBC scenario. I am using the ORDRSP idoc which has multiple segments as below. IDOC -> multiple E1EDK14 segments with 2 fields (QUALF and ORGID) Depending on the value of the QUALF field i n

  • How to start a Servlet on the Startup of my application

              Hai al,           I have an requirtment abt an application on which i need to start a servlet           when my application starts. i am blank abt how to do this. can any body help me           to do ths. Please mention the steps involved i

  • Benefits Declaring Smoker Non Smoker and Rates Based on Choice

    We have requirements from out Benefits department as follows: have an affidavit on the Open Enrollment page on which an employee declares non-tobacco user, tobacco user, or tobacco user but signing up for cessation program. There will be one set of r

  • How to declare a custome AS-class that extend a Flex componenet

    Hello there, would you please help. I have the following mxml tag <mx:Application xmlns:mx="xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:custom="com.myComponents.*" layout="absolute" /> <custom:ReturnData id="dataR" fault="Alert.show(event.fault.fau