Java dates from 0-11 or 1-12

Hello
In java Date, the months ranges from 0-11 . first january is thus 1/0/2003 (in dd/mm/yyyy form). But in almost all databases , month values are counted as 1-12 . That is first january becomes 1/1/2003 . Obviously we have to show the users month values from 1-12 and not from 0-11. This obviuosly places some overhead when doing calculations and display. Sometimes there are situations where we have to get the date from database using getString() function, but that will vary with the result of Resultset.getDate() . Any way to overcome such limitations? and why java has such dates?

I kind of agree. When I first started, I felt that I shouldn't ever rely upon an assumption about the value of a constant field (i.e. Calendar.JANUARY, etc).
But since I did need to have a user-intuitive interface (both in guis and because we deal regularly with processing today's or yesterday's version of a file named like yyyyMMdd.input), I always provided a class that was a day-only object who did its behind-the-scenes work with Calendar by using switch statements to choose the correct Calendar month constants (rather than by adding or subtracting one).
But (a) that got old quick because of either the same cumbersome code repeated everywhere or having to have many otherwise simple standalone programs depend on a central utility class to do this, and (b) the Calendar class documentation states that the value of the month is zero-based, so the horror of assuming constant values is not so bad.
So now I have slightly less cumbersome code (adding or subtracting one) repeated everywhere...

Similar Messages

  • View Object to read data from a java file

    Hi,
    I am using JDeveloper 11.1.1.4 and ADF-BC in my application.
    For one of my view objects , I want the data to be read from a java file which exposes some method to return a collection.
    I cannot use a static view object in this case.
    Please suggest the best way to implement this requirement.Basically build a view object that should read data from a java file.
    Thanks,
    Praveen

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Copying data from one table to another table thru java

    Hi
    I have to copy data from table emp in Database A to table emp in Database B. My input would be table name and number of rows to be fetched. these rows i need to insert in table B.
    The problem over here is I won't be having any info. of table emp i.e the number of columns it has and their type.
    So is their any way i can copy the data from one table to other without having the info abt the number of cols and their type.
    TIA

    Cross post - http://forum.java.sun.com/thread.jspa?threadID=5169293&messageID=9649839#9649839

  • Generating CSV file with column names and data from the MySQL with JAVA

    Hi all,
    Give small example on ...
    How can I add column names and data to a CSV from from MySQL.
    like
    example
    sequence_no, time_date, col_name, col_name
    123, 27-apr-2004, data, data
    234, 27-apr-2004, data, data
    Pls give small exeample on this.
    Thanks & Regards
    Rama Krishna

    Hello Rama Krishna,
    Check this code:
    Example below exports data from MySQL Select query to CSV file.
    testtable structure
    CREATE TABLE testtable
    (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    text varchar(45) NOT NULL,
    price integer not null);
    Application takes path of output file as an argument.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class automateExport {
        public static void main(String[] args) {
            DBase db = new DBase();
            Connection conn = db.connect(
                    "jdbc:mysql://localhost:3306/test","root","caspian");
            if (args.length != 1) {
                System.out.println(
                        "Usage: java automateExport [outputfile path] ");
                return;
            db.exportData(conn,args[0]);
    class DBase {
        public DBase() {
        public Connection connect(String db_connect_str,
                String db_userid, String db_password) {
            Connection conn;
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                conn = DriverManager.getConnection(db_connect_str,
                        db_userid, db_password);
            } catch(Exception e) {
                e.printStackTrace();
                conn = null;
            return conn;
        public void exportData(Connection conn,String filename) {
            Statement stmt;
            String query;
            try {
                stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_UPDATABLE);
                //For comma separated file
                query = "SELECT id,text,price into OUTFILE  '"+filename+
                        "' FIELDS TERMINATED BY ',' FROM testtable t";
                stmt.executeQuery(query);
            } catch(Exception e) {
                e.printStackTrace();
                stmt = null;
    Greetings,
    Praveen Gudapati

  • Query data from MS SQL db through Oracle ? By using JAVA ?

    Hi folks,
    I would like to sync our one table in oracle db with table in different system, stored in MS SQL database.
    What would be the easiest option for connection from Oracle to MS SQL db to be able to query data from MS SQL through some Oracle package?
    If possible, I would like to keep all "tricky steps" within Oracle database. I heard about option with Java, but so far we have no experience with java in Oracle.
    Our database: Oracle 11g Database Standard Edition One
    Many thanks,
    Tomas

    C:\Users\tomeo>dg4pwd HELIOS
    ORACLE Gateway Password Utility
    Constructing password file for Gateway SID HELIOS
    For user account SYSTEM
    OPW-00001: Unable to open password-file (RC=0)
    C:\Users\tomeo>

  • How to read data from the excel file using java code.

    Hi to all,
    I am using below code to getting the data from the excel file but I can't get the corresponding data from the specific file. can anyone give me the correct code to do that... I will waiting for your usefull reply......
    advance thanks....
    import java.io.*;
    import java.sql.*;
        public class sample{
                 public static void main(String[] args){
                      Connection connection = null;
                          try{
                               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                               Connection con = DriverManager.getConnection( "jdbc:odbc:Mydsn","","" );
                               Statement st = con.createStatement();
                               ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
                               System.out.println("sample:"+rs);
                                  ResultSetMetaData rsmd = rs.getMetaData();
                                  System.out.println("samplersd:"+rsmd);
                               int numberOfColumns = rsmd.getColumnCount();
                                  System.out.println("numberOfColumns:"+numberOfColumns);
                                   while (rs.next()) {
                                            System.out.println("sample1:"+rs);
                                            for (int i = 1; i <= numberOfColumns; i++) {
                                                 if (i > 1) System.out.print(", ");
                                                 String columnValue = rs.getString(i);
                                                 System.out.print(columnValue);
                                            System.out.println("");
                                       st.close();
                                       con.close();
                                      } catch(Exception ex) {
                                           System.err.print("Exception: ");
                                           System.err.println(ex.getMessage());
                        }

    1: What is the name of the excel sheet?
    2: What is printed in this program? null ? anything?
    error?Excel file name is "sample.xls" I set excel file connectivity in my JDBC driver(DSN). Here in my program I am not giving that excel file name. I am giving only that excel sheet name. that is followed
    ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );The output of this program is given bellow.
    sample:sun.jdbc.odbc.JdbcOdbcResultSet@1b67f74
    samplersd:sun.jdbc.odbc.JdbcOdbcResultSetMetaData@530daa
    numberOfColumns:2

  • Possible to read data from a web browser into java?

    Is it possible to read data from a web browser such as IE or Mozilla into a java applet for use and manipulation? If it is, could someone please post some documentation I could look at or a snip-it of code I could use? Thanks.

    This will read the content from a site:
    import java.net.*;
    import java.io.*;
    class Test {
         public static void main(String[] argv) throws Exception {
              URL u = new URL("http://www.google.com");
              URLConnection uc = u.openConnection();
              BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
              String text;
              while( (text = br.readLine()) != null ) {
                   System.out.println(text);
    }

  • Static lookup lists:read data from a Java *.properties file

    Hi
    i need to make static lookup lists i am using read data from a Java *.properties file
    i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
    but i need to use the default language for that i update the loadDataFromPropertiesFile()
    method to find the correct properties file
    String temp=Locale.getDefault().getLanguage();
    String propertyFile =
    getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
    the problem:
    For English(TEST_en.properties) it is good and working
    For Arabic(TEST_ar.properties) read from correct file _ar.properties
    but the dispaly character is wrong
    When Debug
    In the File 1=&#1583;&#1605;&#1588;&#1602;
    In debug 1=/u32423

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

  • New JAVA application with data from SAP CRM and R/3

    Hi All,
    We have a requirement to create a new application which will have CRM BP Master data and D&B Data from R/3 and based on authorization different roles be able to edit some of the fields and workflows to confirm the new data .Once users edit the fields in the application the new data will be replicated back into BP Master Data in CRM.
    In our company we are using CRM 7.0 and R/3 4.7 system if we decided to create the application using JAVA can you please let me know the architecture(servers etc) we might need because of the JAVA application.
    How to connect Java application to SAP CRM 7.0. Can you please guide me the data flow structure
    I am not sure if this is the right forum if not please suggest appropriate forum.
    Thanks a lot ,
    Kitcha.

    Hi,
    You can connect to SAP Systems by consuming the RFCs.
    you can use the JCO API to connect to R/3. the [documentation |http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/content.htm]
    alternatively  you can use SAP Enterprise Connector to generate JCO Proxies : [The Documentation|http://help.sap.com/saphelp_nw04/helpdata/EN/ed/897483ea5011d6b2e800508b6b8a93/frameset.htm]
    and somr more helps:
    http://help.sap.com/saphelp_nw04/helpdata/en/89/8a185c148e4f6582560a8d809210b4/frameset.htm
    Regards,
    Naga

  • Sending Data from R/3 to Java and Java to SAP

    Dear All,
    I am working on a scenario in which I have to send data from sap system to Non-SAP system (Java System).
    Now one way is that I made a RFC in my SAP system and Java can call it using JCO adapter. But In this case I am not able to understand how to go another way,means how to capture data or messages from Java.
    Secondly I have searched and found that IDOC can help me lot in this process ,I am new to IDOCS but through R & D , I have made the IDOC and done the following steps:-
    1. Segment Creation (WE31)
    2. IDOC Types          (WE30)
    3. Message Type     (WE81)
    4. Linking Message type and IDOC type (WE82)
    5. Create Distribution Model (BD64)
    Now I am struck on 5th step , I am not able to distribute model when I distribute it I get the following Error
    Target system AII_00_800                  RFC destination for synchronous communication (message type SYNCH)
                                                                 Partner profile LS AII_00_800 SYNCH does not exist
                                                                 Generate partner profile
                                                                  or specify outbound partner profiles for message type SYNCH
    Target system JAVASYS                    RFC destination for synchronous communication (message type SYNCH)
                                                                  Partner profile LS JAVASYS SYNCH does not exist
                                                                 Generate partner profile
                                                                 or specify outbound partner profiles for message type SYNCH
    JAVASYS is the logical system I created using SALE and ALL_00_800 is already there in LS.
    I am not able to understand that my receiver system is NON SAP system so do I have to create logical system for it , and I have IDES system as sender system with only one client 800, what are all the configuration I have to do on SAP side.
    I am also not able to understand where I will write my code to fetch data based on the input provided by NON SAP system as I will have to design IDOC for both Inbound and Outbound processes.
    Kindly help me out, thanks in advance

    Hi Kanagaraja L,
    Thanks for you response.
    No I haven't created Created RFC Destination , this RFC destination will be of my JAVA system ???.
    I have tried creating the partner logical system in WE20 and dine the following steps:
    1. Partner No.   IDES800     Ides 800 System - Sender System
        Partn.Type    LS          Logical system
    2. The tab Post processing : permitted agent is filled with default parameters.
    3. Then in the outbound parameter table control I have pressed the add record button and got a new screen in
        which I have made the following entry :-
      Partner No.           IDES800        Ides 800 System - Sender System
      Partn.Type            LS             Logical system
      Partner Role          LS             Logical system
        Message Type      SYNCH                            ALE:Dummy Message Type for De
        Message code
        Message function
    Under tab Outbound options :
    Receiver Port  = A000000008  (This I have selected from F4 help)
    Basic type = SYNCHRON
    Saved it with the above data.
    Now I am not able to understand how to do the things you have mentioned in 3rd step in your reply.
    What are all the things I have to do kindly tell , as I am very new to Idocs so don't have much knowledge.
    Edited by: Rachit Khanna on Dec 7, 2009 1:49 PM

  • Writing data from Java to Excel

    Hi,
    I am trying to writhe data from Java to an Excel Sheet by using JACOB.
    This is my code :
    import java.util.*;
    import java.io.*;
    //import cost.util.*;
    import com.jacob.com.*;
    import com.jacob.activeX.*;
    class XLStock
         public static void main(String argv[])
              XLStock xls = new XLStock();
              xls.main2(argv);
         public void main2(String argv[])
              System.setSecurityManager(null);
              System.runFinalizersOnExit(true);
              Vector v = new Vector();
              XLSPutItem pi;
              String sheetfile = null;
              ActiveXComponent xl;
              Object xlo=null;
              Object workbooks;
              Object workbook;
              Object sheets;
              Variant vOptn = new Variant();
              vOptn.noParam();
              try
                   xl = new ActiveXComponent("Excel.Application");
                   xlo = xl.getObject();
                   Dispatch.put(xlo, "Visible", new Variant(true));
                   xl.setProperty("Visible", new Variant(true));
                   workbooks = xl.getProperty("Workbooks").toDispatch();
                   Variant vTemp = new Variant(argv[0]);
                   workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method,
                        new Variant[] {vTemp, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn},
                        new int[1]).toDispatch();
                   sheets = Dispatch.get(workbook,"Sheets").toDispatch();
                   pi = new XLSPutItem();
                   if (pi.Parse("1:A1;ciao;6"))
                        v.addElement(pi);
                   for (int i=0; i<v.size(); i++)
                        pi = (XLSPutItem)v.elementAt(i);
                        pi.sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get, new Object[] {new Variant(pi.sheetNumber)}, new int[1]).toDispatch();
                        pi.cell = Dispatch.invoke(pi.sheet, "Range", Dispatch.Get, new Object[] {pi.cellName}, new int[1]).toDispatch();
              catch (Exception e)
                   e.printStackTrace();
              pi = (XLSPutItem)v.firstElement();
              Dispatch.put(pi.cell, "Value", "ciao");
    What happen is that my code always fail at this line :
    xl = new ActiveXComponent("Excel.Application");
    whit this error :
    C:\VJWorks\JNI\jxls>java jxls.XLStock
    com.jacob.com.ComFailException: Can't co-create object
    at com.jacob.com.Dispatch.createInstance(Native Method)
    at com.jacob.com.Dispatch.<init>(Dispatch.java)
    at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
    at jxls.XLStock.main2(XLStock.java:53)
    at jxls.XLStock.main(XLStock.java:28)
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.Vector.firstElement(Vector.java:450)
    at jxls.XLStock.main2(XLStock.java:79)
    at jxls.XLStock.main(XLStock.java:28)
    I task that something is wrong in my system configuration.
    I work on a Win2000 platform and Office 97.
    Someone knows the reason of this error and can suggest what to make.
    Thanks in advance.
    Antonio M.

    Antonio, maybe you can post this back to the Jacob list. As an alternative to Jacob, what about Apache POI or writing the data as comma-delimited and opening the file using Runtime?
    Hope that may help.
    Good luck.

  • How to read data from SAP database in java?

    Hi All ,
    I want to read some tables from SAP database in java? How to connect to SAP database in java.I want to read the data from SAP NetWeaver BW 7.3.
    Please help..

    Download Vder [http://binhgiang.sourceforge.net/site/download.jsp|http://binhgiang.sourceforge.net/site/download.jsp]
    Extract date from website, output to xml format then save to database (MySQL, Oracle,...)
    Screenshot: [http://binhgiang.sourceforge.net/xmlalbum/screenshots.html|http://binhgiang.sourceforge.net/xmlalbum/screenshots.html]
    Edited by: Nhu_Dinh_Thuan on Jul 23, 2009 9:55 PM
    Edited by: Nhu_Dinh_Thuan on Jul 23, 2009 9:56 PM

  • WD Java - Showing Table with data from R/3 backend

    hi folks,
    i have a very novice question.
    we have one rfc-function in abap which is called via adaptive rfc in wd java - it's mostly like the flights-demo.
    I get the data from backend but only one row is shown in the table????
    I guess i made everything correct like in the flights-demo, does anyone has a hint where the problem could be?
    kind regards,
    oliver

    Hi there,
    Where is the data source of your table bound to? Is it to the model node. Check the size() of that node after the bapi call(and invalidate() statement) to check whether data is actually being retrieved.
    Regards,
    LM

Maybe you are looking for

  • How to add a button on the ALV LIST pop up

    Hi , Can any one help me to add a button on the ALV list which is a pop up using ABAP Objects. Thanks in advance. Regards, Kavya.

  • Safari has been terminated unexpectedly

    Hello I have a problem with the Safari browser, which is when I open the browser show me this message "Safari has been terminated unexpectedly." I can not open the browser at all. I hope to resolve the problem quickly.

  • Backing up from the iPod

    Hey. I've got a 14 gb harddrive so i've chosen to use the manually update ipod option to add songs. that way, i can add a song to my ipod, delete it from my computer, and not use up the space on my computer. So i have about 50 songs that i've downloa

  • Will Lion work ok with Logic Pro and 3rd party plugins?

    Will Lion OS work ok with Logic Pro and 3rd party plugins? Any help would be much appreciated, Regards James

  • Panther on Older Macs

    Hi, I would like to put Panther on my iMac G3. It has 128MB of RAM and I can't afford right now to buy more RAM for it, as old RAM is not cheap. I have a copy of Panther that I could install. Will it be slow to the point of unusable? I can deal with