Any java experts pls help me in converting attribute to XML formats

Pls help me oh my god i am a newbie here and i am given this project.
I had just written a XML doc. which looks like this
<ConsumerTransfer>
<TransactionId>
123:123
</TransactionId>
<Billingoption>
cash
</Billingoption>
</ConsumerTransfer>
I need to make this to attributes like
private String TransactionId()
private String BillingOption()
and so on.....
I need to convert this attributes to XML format
can any show me an example or the source codes for this
Really, I appreciate it.
JimmyKnot

For such node level operations I think that DOM would be a good idea. So here you go. Look for some nice tutorial for DOM and you got it.
salut

Similar Messages

  • Any Java experts,please help this Newbie.

    Hey,any one of you knows how do you call a program from a button?
    For example,I created a chat program and peer to peer share Program,and I want to join them together.
    By clicking on a button on the peer to peer share program,the chat program would open in a new window.
    Please Help Me!
    Thanks alot.

    Hi here is the complete example for you how you can call the other java classes in your main java class. Hope it will give you the idea. If still you have problems do write to me at [email protected]
    * SixFrame.java
    * Created on July 15, 2003, 10:26 AM
    * @author sandeep
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class SixFrame extends JFrame implements ActionListener{
    JButton btn[] = new JButton[6]; // this no will vary as per you requirements
    /** Creates a new instance of SixFrame */
    public SixFrame() {
    JPanel pan = new JPanel();
    for(int i=0;i<btn.length;i++){
    btn[i] = new JButton((i+1)+"");
    btn.addActionListener(this);
    pan.add(btn[i]);
    getContentPane().add(pan,BorderLayout.CENTER);
    setSize(300,300);
    setVisible(true);
    /** Invoked when an action occurs.
    public void actionPerformed(ActionEvent e) {
    String comm = e.getActionCommand();
    if(comm.equals("1")){
    new FrameOne("One");
    }else if(comm.equals("2")){
    new FrameTwo("Two");
    }else if(comm.equals("3")){
    new FrameThree("Three");
    }else if(comm.equals("4")){
    new FrameFour("Four");
    }else if(comm.equals("5")){
    new FrameFive("Five");
    }else if(comm.equals("6")){
    new FrameSix("Six");
    public static void main(String args[]){
    new SixFrame();
    class FrameOne extends JFrame{
    FrameOne(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameTwo extends JFrame{
    FrameTwo(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameThree extends JFrame{
    FrameThree(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameFour extends JFrame{
    FrameFour(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameFive extends JFrame{
    FrameFive(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameSix extends JFrame{
    FrameSix(String str){
    super(str);
    setSize(200,200);
    setVisible(true);

  • Can any Java expert help me? Urgent.

    I create a table---CourseDB in adatabase to store the Student ID ( student identification number) and the grades of the courses that they took.
    The structure of the table---CourseDB is:
    StudentID
    GradeofCourse1
    GradeofCourse2
    GradeofCourse3
    GradeofCourseN
    Here GradeofCourse1 means the grade of course 1, that the student obtained. GradeofCourse2, GradeofCourse3, GradeofCourseN have the same meaning.
    I want to use the following query to count the students
    who get g1 in course 1, and g2 in course 2, ......and gn in
    course n.
    Select COUNT(*)
    From CourseDB
    Where GradeofCourse1=g1 AND GradeofCourse2= g2
    ......AND GradeofCourseN=gn
    Here g1, g2,......,gn are grade, the values are: A,B,C,D.
    I want to consider all the possible combination of g1,g2,...,gn.
    The students take all the n courses:Course 1, Course 2,...., Course n, and may get A,B,C, or D in the n courses.
    For example:
    g1=A,g2=B,g3=C,.....,gn=D
    ( This means that the student gets A in Course 1, gets B in Course 2, gets C in Course 3,....., gets D in Course n. Many students may have the same situation. I want to know how many are the students?)
    Or:
    g1=B,g2=C,g3=D,......,gn=A
    To make the problem clear, I give a detail example:
    For example, there are two courses: course 1, course 2.
    I want to know how many stuent get "A" in course 1 and
    get "B" in course 2 at the same time.
    And I want to know all the grade combination of the two courses:
    course 1 course 2
    A A
    A B
    A C
    A D
    B A
    B B
    B C
    B D
    C A
    C B
    C C
    C D
    D A
    D B
    D C
    D D
    So that's 16 total combinations(4^2).
    My question is in the code how I can assign the values(A,B,C,D)
    to g1,g2,g3,.....,gn conveniently.
    The following "nested for loop" can solve the problem ( for example, there are 6 courses):
    for (char class1 = 'A'; class1 <= 'D'; class1++)
    for (char class2 = 'A'; class1 <= 'D'; class2++)
    for (char class3 = 'A'; class1 <= 'D'; class3++)
    for (char class4 = 'A'; class1 <= 'D'; class4++)
    for (char class5 = 'A'; class1 <= 'D'; class5++)
    for (char class6 = 'A'; class1 <= 'D'; class6++)
    select count(*)
    from CourseDB
    where GradeofCourse1=class1 AND GradeofCourse2 = class2 AND GradeofCourse3 = class3
    ....AND GradeofCourse6=class6
    But the problem is that in the "Where GradeofCourse1=class1 AND
    GradeofCourse2= class2 ......AND GradeofCourse6=class6" of the
    Query, the number of courses is not fixed, maybe six, maybe three,
    maybe four, so the depth of "nested for loop" can not be fixed.
    Can any Java expert give me some suggestions?
    Thanks in advance.
    Jack

    Jack,
    When you posted this on the other forum, it was quite a different question, but it has mutated to this point now. I believe what you want to do can be done with what MS Access calls a crosstab query and you can completely leave Java and any other programming language out of it. If you need to know how to do a crosstab query please take it to another forum.

  • QUERY CLARIFICATION RQD :  gurus, experts pls help

    Hai,
    I am facing problem in performance of the query. sample scenario i have created here pls help me to solve
    **VEH_MAIN* TABLE (MASTER TABLE)*
    CREATE TABLE VEH_MAIN
       (     VIP_MOT_IND VARCHAR2(10 BYTE),
         VIP_IND NUMBER(10,0)
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',1);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',5);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('M0T03',1);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',2);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',6);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',3);
    Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',4);
    **VEH_ENGINE_SUB* (table for engine subclass)*
      CREATE TABLE VEH_ENG_SUB
       (     ENG_SUBCLASS VARCHAR2(50 BYTE),
         ENG_MOT_IND VARCHAR2(10 BYTE)
    Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT01');
    Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT02');
    *VEH_ENG_IND( Detail table for engine subclass)*
      CREATE TABLE VEH_ENG_IND
       (     "ENG_SUBCLASS" VARCHAR2(50 BYTE),
         "ENG_IND" VARCHAR2(10 BYTE)
    Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','1');
    Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','2');
    *VEH_AXIS( Master table for Engine Axis)*
    CREATE TABLE VEH_AXIS
       (     ENG_AXIS VARCHAR2(50 BYTE),
         AXIS_MOT_IND VARCHAR2(10 BYTE)
    Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS001','MOT01');
    Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS002','MOT02');
    *VEH_AXIS_IND( Details table for engine axis)*
    CREATE TABLE VEH_AXIS_IND
       (     ENG_AXIS VARCHAR2(50 BYTE),
         ENG_IND VARCHAR2(10 BYTE)
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','1');
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','2');
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','3');
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','4');
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','5');
    Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','6');
    Condition 1
    if i select only ENGINE_SUBCLASS='ENGSUB001' then
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_eng_sub vsub,
    veh_eng_ind  vind
    WHERE (v.vip_mot_ind= vsub.eng_mot_ind
    and   v.vip_ind=vind.eng_ind
    and    vsub.eng_subclass= vind.eng_subclass
    AND vsub.eng_subclass='ENGSUB001' )output is
    MOT01     1
    MOT01     2
    Condition 2:if i select only the Engine Axis='ENGAXIS002' then the
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_axis  vaxis,
    veh_axis_ind vaind
    WHERE  v.vip_mot_ind= vaxis.axis_mot_ind
    and   v.vip_ind= vaind.eng_ind
    and   vaind.eng_axis= vaxis.eng_axis
    and   vaxis.eng_axis='ENGAXIS002';MOT02     5
    MOT02     6
    Condition 3:
    BOTH ENGINE AXIS AND ENGINE SUBCLASS
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_eng_sub vsub,
    veh_eng_ind  vind,
    veh_axis  vaxis,
    veh_axis_ind vaind
    WHERE (v.vip_mot_ind= vsub.eng_mot_ind
    and   v.vip_ind=vind.eng_ind
    and    vsub.eng_subclass= vind.eng_subclass
    AND vsub.eng_subclass='ENGSUB001' )
    AND  ( v.vip_mot_ind= vaxis.axis_mot_ind
    and   v.vip_ind= vaind.eng_ind
    and   vaind.eng_axis= vaxis.eng_axis
    and   vaxis.eng_axis='ENGAXIS002');Null values returned. this is correct.
    But the query PERFORMANCE fails in OR CONDITON as below
    Condition 4;
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_eng_sub vsub,
    veh_eng_ind  vind,
    veh_axis  vaxis,
    veh_axis_ind vaind
    WHERE (v.vip_mot_ind= vsub.eng_mot_ind
    and   v.vip_ind=vind.eng_ind
    and    vsub.eng_subclass= vind.eng_subclass
    AND vsub.eng_subclass='ENGSUB001' )
    OR  ( v.vip_mot_ind= vaxis.axis_mot_ind
    and   v.vip_ind= vaind.eng_ind
    and   vaind.eng_axis= vaxis.eng_axis
    and   vaxis.eng_axis='ENGAXIS002');output
    MOT02     5
    MOT02     5
    MOT02     5
    MOT02     5
    MOT02     6
    MOT02     6
    MOT02     6
    MOT02     6
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     1
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    MOT01     2
    This is sample example. when i implement in huge table with partition this scennario takes much time even 2 hours to run.
    i want the output must be as below if i use OR condition like condition 4
    MOT01     1
    MOT01     2
    MOT02     5
    MOT02     6
    Gurus and experts pls help me to solve this problem. Dont give any suggestion like
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_axis  vaxis,
    veh_axis_ind vaind
    WHERE  v.vip_mot_ind= vaxis.axis_mot_ind
    and   v.vip_ind= vaind.eng_ind
    and   vaind.eng_axis= vaxis.eng_axis
    and   vaxis.eng_axis='ENGAXIS002'
    union
    SELECT  vip_mot_ind,vip_ind
    FROM veh_main V,
    veh_eng_sub vsub,
    veh_eng_ind  vind
    WHERE (v.vip_mot_ind= vsub.eng_mot_ind
    and   v.vip_ind=vind.eng_ind
    and    vsub.eng_subclass= vind.eng_subclass
    AND vsub.eng_subclass='ENGSUB001' )
    }this will give correct result...
    MOT01     1
    MOT01     2
    MOT02     5
    MOT02     6
    but the problem is we cannot implement this in query. because query get framed at runtime there will be so many implement has to be done. other than UNION pls give me more suggesion
    waiting..
    S
    Edited by: A Beginner on Sep 11, 2010 12:51 AM

    create a view v1 with all the joins
    select * from v1 where eng_subclass='ENGSUB001'
    union
    select * from v1 where eng_axis='ENGAXIS002'
    If you really do not like the direct access with union, try this
    select * from v1
    where vsub_PK in (select vsub_PK from v1 where eng_subclass='ENGSUB001' )
    OR vsub_PK in (select vsub_PK from v1 where eng_axis='ENGAXIS002')
    --vsub_PK is the primary key of table vsub                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Converting String To XML Format and send as attachment

    Hi
    My requirement is to convert String into XML Format and that XML File i have to send as an attachment
    can any one one give solution for this Problem.
    Thank you
    Venkatesh.K

    hi,
    i m filling the itab first and converting to xml
    itab contaning these data
    GS_PERSON-CUST_ID   = '3'.
    GS_PERSON-FIRSTNAME = 'Bill'.
    GS_PERSON-LASTNAME  = 'Gates'.
    APPEND GS_PERSON TO GT_PERSON.
    GS_PERSON-CUST_ID   = '4'.
    GS_PERSON-FIRSTNAME = 'Frodo'.
    GS_PERSON-LASTNAME  = 'Baggins'.
    APPEND GS_PERSON TO GT_PERSON.
    after conversion data is coming like that
    #<?xml version="1.0" encoding="utf-16"?>
    <CUSTOMERS>
      <item>
        <customer_id>0003</customer_id>
        <first_name>Bill</first_name>
        <last_name>Gates</last_name>
      </item>
      <item>
        <customer_id>0004</customer_id>
        <first_name>Frodo</first_name>
        <last_name>Baggins</last_name>
      </item>
    </CUSTOMERS>
    but errors are  1) # is coming at the first
                            2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
    can anybody plz solve it.
    regards,
    viki

  • Converting string to XML format

    Hi All,
    I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
    <VALUE005>20387899.437</VALUE005>
    <VALUE006>20387899.437</VALUE006>
    Is there any function module for this.

    Chk this thread.
    Re: Regd: File Conversion to XML format

  • Am not able to run the java program - pls help

    1. I installed java in the below path
         c:\program files\java\jdk1.5.0
         c:\program files\java\jre1.5.0
    I set the path in
         User variable i. variable name: path
              ii. variable value: c:\program files\java\jdk1.5.0\bin
    when I compile it in command prompt-applying javac ? it performed successfully-shows
    options like ?g create all debug info, -g : new Generate no debug info etc.,
    But am not able to run the file. It shows error msg.
    2. I specified the same name for file name & class name.
    3. Java <class name>
         Exception in thread ?main?java.lang.NoclassDeffoundError: <class name>
    4. Java ?cp <class name>
         Unrecognized option: -cp.<classname>
         Could not create the Java Virtual Machine
    5. Java ?classpath . <classname>
         Exception in thread ?main?.java.lang.unsupported classversionError: <classname>
         <unsupported major.minor version 49.0
              at java.lang.classloader.defineclass0<native method>
              at java.lang.classloader.defineclass<unknown source>
                   --and many listed below?
    6. Java ?classpath c:\program files\java\jdk1.5.0\bin <class name>
         Exception in thread ?main?java.lang.NoclassDeffoundError: <class name>
    7. I re-installed the java, but still the problem continuing.
    pls help... its very urgent

    Is the java class you compiled/calling in the default package? If it is not, you will have to call it by the fully qualified name.
    e.g.
    package com.mycompany.myproject;
    public class MyClass {
        public static void main(String[] args) { }
    }This would be called as "Java com.mycompany.myproject.MyClass" and must contain a main method with signature as above.
    You would have to call this from folder where the compiled classes are located. If using package, you would call from directory at level of top most package so com folder in this example as Java will look at each package name in qualified name and try to traverse directories with those same names to get to .class file matching class name specified. To avoid this, your newly compiled .class files must also be in your classpath.
    Hopefully that helps.
    --Kevin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • URGENT!! all the JAVA EXPERTS plssss help me!!

    thanks for replying me....i m actually doing a coursework that i have to submit by next monday 29/4/2002. and i havent finish it yet.... ok .. finally i have finish level 1, now i m doing level two...
    my program in level 2 should :
    a.) Allow the user to specify certain criteria for a room that they wish to book on a particular day. e.g. X number of people, video conferencing, your program should find an appropriate room for them that is free on that day.
    b.) Allow the user to add more rooms to the system and make these available to the user to book.
    c.) Allow a user to attempt to delete a room. The room will only be deleted if it has no bookings.
    d.) Allow the user to ask the system to find the minimum fit room free e.g.
    * the smallest room to hold X people that has a connection to the internet.
    * if the user requests a room for 40 people and there are rooms free for 50 and 60 people, then
    it will allocate them the room for 50.
    i really donno how to do....pls help me....
    there is something wrong in the METHOD --> AddDeleteRoom()
    and i donno how to code the AddNewRoom()
    i need to add more rooms into my array
    u can download these coding .....i got three files, 1 is the main class call CC.java, another 1 is the class filewhich is Rooms.java and the third file is CC.html file.
    dont worry, u can save all the coding in here.... i try b4 it can run.....
    <<save as CC.java>>
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.JApplet;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.JOptionPane;
    public class CC extends JApplet implements ActionListener,ItemListener
    JPanel pnlPane = new JPanel();
    JPanel pnlChoise = new JPanel();
    JPanel pnlButton2 = new JPanel();
    JPanel pnlRoomDisplay = new JPanel();
    JPanel pnlRoom = new JPanel();
    JPanel pnlDisplay = new JPanel();
    JPanel pnlClear = new JPanel();
    JButton btnDisplay = new JButton("Display");
    JButton btnBookRoom = new JButton("Book Room");
    JButton btnDelBookRoom = new JButton("Delete Booking");
    JButton btnDelRoom = new JButton("Delete Room");
    JButton btnAddNewRoom = new JButton("Add New Room");
    JButton btnClear = new JButton("Clear");
    JButton btnRoomQuery = new JButton("Room Query");
    Rooms []room = new Rooms[11];
    String[] Days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    int [][] book = new int[11][7];
    public int R, D;
    JLabel lblRoomName = new JLabel();
    JLabel lblCapacity = new JLabel();
    JLabel lblInternet = new JLabel();
    JLabel lblVideo = new JLabel();
    JLabel lblStatus = new JLabel();
    JComboBox cDays= new JComboBox(Days);
    JComboBox cRooms = new JComboBox();
    JTextField txtRoomName1 = new JTextField();
    JTextField txtCapacity1 = new JTextField();
    JCheckBox chkInternet = new JCheckBox("Internet Connection");
    JCheckBox chkVideo = new JCheckBox("Video Conferencing");
    JTextArea txtDisplay = new JTextArea("*****Rooms Detail*****" + "\n",12,30);
    public void init()
    pnlPane.add(pnlChoise);
    pnlPane.add(pnlButton2);
    pnlPane.add(pnlRoomDisplay);
    pnlPane.add(pnlRoom);
    pnlPane.add(pnlDisplay);
    pnlPane.add(pnlClear);
    pnlPane.setBorder(new TitledBorder(new BevelBorder(BevelBorder.RAISED),"Room Booking System"));
    setContentPane(pnlPane);
    AddChoisePanel();
    AddButton2Panel();
    AddRoomDisplayPanel();
    AddRoomPanel();
    AddDisplayAreaPanel();
    AddClearPanel();
    public void AddChoisePanel()
    pnlChoise.setLayout(new GridLayout(1,3,5,5));
    room[0]=new Rooms("Barrington","15","No","Yes");
    room[1]=new Rooms("Carlton","25","Yes","No");
    room[2]=new Rooms("Debyshire","35","No","No");
    room[3]=new Rooms("Edwards","30","Yes","Yes");
    room[4]=new Rooms("Farley","70","Yes","No");
    room[5]=new Rooms("Goodwin","80","Yes","Yes");
    room[6]=new Rooms("Harlow","90","No","Yes");
    room[7]=new Rooms("IlFord","85","No","No");
    for (int i=0; i<8; i++)
    cRooms.addItem(room.rName);
    pnlChoise.add(cRooms);
    pnlChoise.add(cDays);
    pnlChoise.add(btnRoomQuery);
    btnRoomQuery.addActionListener(this);
    cRooms.addItemListener(this);
    public void AddButton2Panel()
    pnlButton2.setLayout(new GridLayout(1,2,5,5));
    pnlButton2.add(btnBookRoom);
    pnlButton2.add(btnDelBookRoom);
    btnDelBookRoom.addActionListener(this);
    btnBookRoom.addActionListener(this);
    public void AddRoomDisplayPanel()
    pnlRoomDisplay.setLayout(new GridLayout(6,2,5,2));
    pnlRoomDisplay.add(new JLabel("Room Name" ));
    pnlRoomDisplay.add(lblRoomName);
    pnlRoomDisplay.add(new JLabel("Room Capacity"));
    pnlRoomDisplay.add(lblCapacity);
    pnlRoomDisplay.add(new JLabel("Internet Connection"));
    pnlRoomDisplay.add(lblInternet);
    pnlRoomDisplay.add(new JLabel("Video Conferencing"));
    pnlRoomDisplay.add(lblVideo);
    pnlRoomDisplay.add(new JLabel("Room Status"));
    pnlRoomDisplay.add(lblStatus);
    pnlRoomDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    pnlRoomDisplay.add(btnDelRoom);
    btnDelRoom.addActionListener(this);
    public void AddRoomPanel()
    pnlRoom.setLayout(new GridLayout(6,2,2,2));
    pnlRoom.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Add New Rooms"));
    pnlRoom.add(new Label("Room Name"));
    pnlRoom.add(txtRoomName1);
    pnlRoom.add(new Label("Capacity"));
    pnlRoom.add(txtCapacity1);
    pnlRoom.add(chkInternet);
    pnlRoom.add(new Label(""));
    pnlRoom.add(chkVideo);
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(btnAddNewRoom);
    btnAddNewRoom.addActionListener(this);
    public void AddDisplayAreaPanel()
    pnlDisplay.setLayout(new GridLayout(1,1));
    //pnlDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    Border pnlDisplayBorder = BorderFactory.createTitledBorder("Rooms Detail");
    pnlDisplay.setBorder(pnlDisplayBorder);
    pnlDisplay.add(txtDisplay);
    public void AddClearPanel()
    pnlClear.setLayout(new GridLayout(1,1));
    pnlClear.add(btnClear);
    btnClear.addActionListener(this);
    public void actionPerformed(ActionEvent event)
    //to call RoomQuery function
    if (event.getSource() == btnRoomQuery){
    AddRoomQuery(); }
    else
    //to call DeleteBookRoom function
    if (event.getSource() == btnDelBookRoom){
    AddDeleteBookRoom(); }
    else
         //to call DeleteRoom function
    if (event.getSource() == btnDelRoom){
              AddDeleteRoom(); }     
         else
         //to call AddNewRoom function
         if (event.getSource() == btnAddNewRoom){
                   AddNewRoom(); }
              else
              //to call ClearTextArea function
                   if (event.getSource() == btnClear){
                   AddClearTextArea(); }
              else
                   //to call BookRoom function
                   if (event.getSource() == btnBookRoom){
                        AddBookRoom(); }
    public void AddRoomQuery()
    R= (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    JOptionPane.showMessageDialog(null, R + " " + D);
    txtDisplay.setText(" *************** Room Status For "+ Days[D] + " *************** " + "\n");
    txtDisplay.append("Rooms" + "\t\t " + " Status");
    for (int t=0; t< (int) cRooms.getItemCount(); t++)
    {  JOptionPane.showMessageDialog(null," is" + cRooms.getItemCount());
    if (book[t][D]==0)
    txtDisplay.append("\n" + ">>" + room[t].rName);
    txtDisplay.append("\t\t " + " Room is Available");
    else
         if (book[t][D]==1)
    txtDisplay.append("\n" + ">>" + room[t].rName);
         txtDisplay.append("\t\t " + " Room Booked");
    JOptionPane.showMessageDialog(null, "end " );
    public void AddDeleteBookRoom()
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    if(book[R][D] == 1)
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Available" + "\n");
    book[R][D] = 0;
    else
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Available"+ "\n");
         book[R][D] = 0;
    public void AddDeleteRoom()
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    JOptionPane.showMessageDialog(null,"Room selected index " + R);
    int intCount =(int) cRooms.getSelectedIndex();
    if (intCount != -1)
    if(book[R][D] == 0 )
    JOptionPane.showMessageDialog(null,"Room "+room[intCount].rName + " had Deleted");
    cRooms.removeItemAt(intCount);
    int i;
    for( i=intCount;i< cRooms.getItemCount();i++)
    JOptionPane.showMessageDialog(null,"Room "+room[i+1].rName + "to");      
    room[i]=new Rooms(room[i+1]);
    JOptionPane.showMessageDialog(null,"Room "+ room[i].rName );
    //cRooms.getSelectedIndex());
    // intCount--;
    else
    if(book[R][D] == 1 )
    JOptionPane.showMessageDialog(null,"Room "+room[intCount].rName+" Can Not be Delete");
    else
    JOptionPane.showMessageDialog(null,"Select A Room To be Delete ");
    public void AddNewRoom()
    JOptionPane.showMessageDialog(null,"Add new room");
    public void AddClearTextArea()
    txtDisplay.setText("*****Rooms Detail*****" + "\n");
    public void AddBookRoom()
    R= (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    if(book[R][D] == 0)
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Booked" + "\n");
    book[R][D] = 1;
    else
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Not Available"+ "\n");
         book[R][D] = 1;
    public void itemStateChanged(ItemEvent itv)
    if( itv.getSource() == cRooms )
    R = (int) cRooms.getSelectedIndex();
    lblRoomName.setText(room[R].rName);
    lblCapacity.setText(room[R].rCapacity);
    lblInternet.setText(room[R].rInternet);
    lblVideo.setText(room[R].rVideo);
    // lblStatus.setText(room[R].rStatus);
    <<save as Rooms.java>>
    public class Rooms
    String rName;
    String rCapacity;
    String rInternet;
    String rVideo;
    // String rStatus;
    Rooms(String a, String b, String c, String d)//, String e)
    rName = a;
    rCapacity = b;
    rInternet = c;
    rVideo = d;
    // rStatus = e;
    Rooms(Rooms r)
    rName = r.rName;
    rCapacity = r.rCapacity;
    rInternet = r.rInternet;
    rVideo = r.rVideo;
    // rStatus = r.e;
    <<saves as CC.html>>
    <html>
    <body>
    <Applet code = CC.class
    width = 600
         height = 510>
    </Applet>
    </body>
    </html>

    The important thing is to put the related functionality in the class Room and not everywhere in the class CC.
    The types of the data member in the class Room are also very important to reflect exactly what they should store.
    Here I post a new version of your files as example of how we can improve your version. It does not implement all the functionality you will need but it is a first step.
    Serge
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.JApplet;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.JOptionPane;
    import java.util.LinkedList;
    public class CC extends JApplet implements ActionListener, ItemListener {
        JPanel pnlPane = new JPanel();
        JPanel pnlChoise = new JPanel();
        JPanel pnlButton2 = new JPanel();
        JPanel pnlRoomDisplay = new JPanel();
        JPanel pnlRoom = new JPanel();
        JPanel pnlDisplay = new JPanel();
        JPanel pnlClear = new JPanel();
        JButton btnDisplay = new JButton("Display");
        JButton btnBookRoom = new JButton("Book Room");
        JButton btnDelBookRoom = new JButton("Delete Booking");
        JButton btnDelRoom = new JButton("Delete Room");
        JButton btnAddNewRoom = new JButton("Add New Room");
        JButton btnClear = new JButton("Clear");
        JButton btnRoomQuery = new JButton("Room Query");
        LinkedList roomList = new LinkedList();
        String[] Days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
        public int R, D;
        JLabel lblRoomName = new JLabel();
        JLabel lblCapacity = new JLabel();
        JLabel lblInternet = new JLabel();
        JLabel lblVideo = new JLabel();
        JLabel lblStatus = new JLabel();
        JComboBox cDays = new JComboBox(Days);
        JComboBox cRooms = new JComboBox();
        JTextField txtRoomName1 = new JTextField();
        JTextField txtCapacity1 = new JTextField();
        JCheckBox chkInternet = new JCheckBox("Internet Connection");
        JCheckBox chkVideo = new JCheckBox("Video Conferencing");
        JTextArea txtDisplay = new JTextArea("*****Rooms Detail*****" + "\n", 12, 30);
        public void init() {
            pnlPane.add(pnlChoise);
            pnlPane.add(pnlButton2);
            pnlPane.add(pnlRoomDisplay);
            pnlPane.add(pnlRoom);
            pnlPane.add(pnlDisplay);
            pnlPane.add(pnlClear);
            pnlPane.setBorder(new TitledBorder(new BevelBorder(BevelBorder.RAISED), "Room Booking System"));
            setContentPane(pnlPane);
            AddChoisePanel();
            AddButton2Panel();
            AddRoomDisplayPanel();
            AddRoomPanel();
            AddDisplayAreaPanel();
            AddClearPanel();
        public void AddChoisePanel() {
            pnlChoise.setLayout(new GridLayout(1, 3, 5, 5));
            Room[]room = new Room[8];
            room[0] = new Room("Barrington", "15", false, true);
            room[1] = new Room("Carlton", "25", true, false);
            room[2] = new Room("Debyshire", "35", false, false);
            room[3] = new Room("Edwards", "30", true, true);
            room[4] = new Room("Farley", "70", true, false);
            room[5] = new Room("Goodwin", "80", true, true);
            room[6] = new Room("Harlow", "90", false, true);
            room[7] = new Room("IlFord", "85", false, false);
            for (int i = 0; i < 8; i++) {
                cRooms.addItem(room.getName());
    roomList.add(room[i]);
    pnlChoise.add(cRooms);
    pnlChoise.add(cDays);
    pnlChoise.add(btnRoomQuery);
    btnRoomQuery.addActionListener(this);
    cRooms.addItemListener(this);
    public void AddButton2Panel() {
    pnlButton2.setLayout(new GridLayout(1, 2, 5, 5));
    pnlButton2.add(btnBookRoom);
    pnlButton2.add(btnDelBookRoom);
    btnDelBookRoom.addActionListener(this);
    btnBookRoom.addActionListener(this);
    public void AddRoomDisplayPanel() {
    pnlRoomDisplay.setLayout(new GridLayout(6, 2, 5, 2));
    pnlRoomDisplay.add(new JLabel("Room Name"));
    pnlRoomDisplay.add(lblRoomName);
    pnlRoomDisplay.add(new JLabel("Room Capacity"));
    pnlRoomDisplay.add(lblCapacity);
    pnlRoomDisplay.add(new JLabel("Internet Connection"));
    pnlRoomDisplay.add(lblInternet);
    pnlRoomDisplay.add(new JLabel("Video Conferencing"));
    pnlRoomDisplay.add(lblVideo);
    pnlRoomDisplay.add(new JLabel("Room Status"));
    pnlRoomDisplay.add(lblStatus);
    pnlRoomDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED), "Rooms Detail"));
    pnlRoomDisplay.add(btnDelRoom);
    btnDelRoom.addActionListener(this);
    public void AddRoomPanel() {
    pnlRoom.setLayout(new GridLayout(6, 2, 2, 2));
    pnlRoom.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED), "Add New Rooms"));
    pnlRoom.add(new Label("Room Name"));
    pnlRoom.add(txtRoomName1);
    pnlRoom.add(new Label("Capacity"));
    pnlRoom.add(txtCapacity1);
    pnlRoom.add(chkInternet);
    pnlRoom.add(new Label(""));
    pnlRoom.add(chkVideo);
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(btnAddNewRoom);
    btnAddNewRoom.addActionListener(this);
    public void AddDisplayAreaPanel() {
    pnlDisplay.setLayout(new GridLayout(1, 1));
    //pnlDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    Border pnlDisplayBorder = BorderFactory.createTitledBorder("Rooms Detail");
    pnlDisplay.setBorder(pnlDisplayBorder);
    pnlDisplay.add(txtDisplay);
    public void AddClearPanel() {
    pnlClear.setLayout(new GridLayout(1, 1));
    pnlClear.add(btnClear);
    btnClear.addActionListener(this);
    public void actionPerformed(ActionEvent event) {
    //to call RoomQuery function
    if (event.getSource() == btnRoomQuery) {
    AddRoomQuery();
    } else {
    //to call DeleteBookRoom function
    if (event.getSource() == btnDelBookRoom) {
    AddDeleteBookRoom();
    } else {
    //to call DeleteRoom function
    if (event.getSource() == btnDelRoom) {
    AddDeleteRoom();
    } else {
    //to call AddNewRoom function
    if (event.getSource() == btnAddNewRoom) {
    AddNewRoom();
    } else {
    //to call ClearTextArea function
    if (event.getSource() == btnClear) {
    AddClearTextArea();
    } else {
    //to call BookRoom function
    if (event.getSource() == btnBookRoom) {
    AddBookRoom();
    public void AddRoomQuery() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    // JOptionPane.showMessageDialog(null, R + " " + D);
    txtDisplay.setText(" *************** Room Status For " + Days[D] + " *************** " + "\n");
    txtDisplay.append("Rooms" + "\t\t " + " Status");
    Room aRoom = (Room)roomList.get(R);
    for (int t = 0; t < (int) cRooms.getItemCount(); t++) {
    // JOptionPane.showMessageDialog(null, " is" + cRooms.getItemCount());
    aRoom = (Room)roomList.get(t);
    txtDisplay.append("\n" + ">>" + aRoom.getName());
    if (aRoom.isBooked(D)) {
    txtDisplay.append("\t\t " + " Room Booked");
    } else {
    txtDisplay.append("\t\t " + " Room is Available");
    // JOptionPane.showMessageDialog(null, "end ");
    public void AddDeleteBookRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    aRoom.checkOut(D);
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Available" + "\n");
    public void AddDeleteRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    // JOptionPane.showMessageDialog(null, "Room selected index " + R);
    int intCount = (int) cRooms.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    if (intCount != -1) {
    if (aRoom.isBooked() == false) {
    JOptionPane.showMessageDialog(null, "Room " + ((Room)roomList.get(intCount)).getName() + " had Deleted");
    cRooms.removeItemAt(intCount);
    roomList.remove(intCount);
    } else {
    JOptionPane.showMessageDialog(null, "Room " + ((Room)roomList.get(intCount)).getName() + " Can Not be Delete");
    } else {
    JOptionPane.showMessageDialog(null, "Select A Room To be Delete ");
    public void AddNewRoom() {
    String rName = txtRoomName1.getText();
    String rCapacity = txtCapacity1.getText();
    boolean rInternet = chkInternet.isSelected();
    boolean rVideo = chkVideo.isSelected();
    Room nRoom = new Room(rName,rCapacity,rInternet,rVideo);
    cRooms.addItem(rName);
    int i = cRooms.getItemCount();
    roomList.add(nRoom);
    public void AddClearTextArea() {
    txtDisplay.setText("*****Rooms Detail*****" + "\n");
    public void AddBookRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    if (aRoom.reserve(D) == 0) {
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Booked" + "\n");
    } else {
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Not Available" + "\n");
    public void itemStateChanged(ItemEvent itv) {
    if (itv.getSource() == cRooms) {
    R = (int) cRooms.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    lblRoomName.setText(aRoom.getName());
    lblCapacity.setText(String.valueOf(aRoom.getCapacity()));
    lblInternet.setText(aRoom.getInternet());
    lblVideo.setText(aRoom.getVideo());
    // lblStatus.setText(aRoom.rStatus);
    public class Room {
    public final String YES = "Yes";
    public final String NO = "No";
    private String rName = null;
    private int rCapacity = 0;
    private boolean rInternet = false;
    private boolean rVideo = false;
    private boolean [] booked = { false, false, false, false, false, false, false };
    Room(String name, String capacity, boolean hasInternet, boolean hasVideo)
    rName = new String(name);
    rCapacity = Integer.parseInt(capacity);
    rInternet = hasInternet;
    rVideo = hasVideo;
    public int reserve(int day) {
    if (booked[day] == true)
    return -1;
    booked[day] = true;
    return 0;
    public void checkOut(int day) {
    booked[day] = false;
    public boolean isBooked() {
    for (int i = 0; i < booked.length; i++)
    if (booked[i] == true)
    return true;
    return false;
    public boolean isBooked(int day) {
    return booked[day];
    public String getName() {
    return rName;
    public int getCapacity() {
    return rCapacity;
    public String getInternet() {
    if (rInternet == false)
    return NO;
    return YES;
    public String getVideo() {
    if (rVideo == false)
    return NO;
    return YES;
    public boolean matchCriterias(boolean hasInternet, boolean hasVideo) {
    if ((hasInternet == rInternet) && (hasVideo == rVideo))
    return true;
    return false;

  • My mac air died, after i reinstall from dvd drive, when i boot up again, i saw a prohibit sign showing up on the screen, then get to my logon screen.  After logon, it takes very long time to load any application.  pls help

    my mac air died, after i reinstall from dvd drive, when i boot up again, i saw a prohibit sign showing up on the screen, then get to my logon screen.  After logon, it takes very long time to load any application.  pls help

    OK. If you believe that.
    When the disk is starting to die it can be bad for a moment and then be good for a while. If there was no problem while you were checking it of course it shows up good.
    I tell you those are the signs of a disk that is about to die.
    Allan

  • Hi experts pls help me with this materialized view refresh time!!!

    Hi Expeerts ,
    Please clarify my doubt about this materialized view code
    [\n]
    CREATE MATERIALIZED VIEW SCHEMANAME.products_mv
    REFRESH WITH ROWID
    AS SELECT * from VIEW_TABLE@DATAOPPB;
    [n]
    Here i am creating a materialized view named products_mv of the view_table present in the remote server.Can anyone tell me when will my table product_mv will get refreshed if i follow this code.As what i read from the books is that the refresh period is implicit and is carried out by the database implicitly.so can u tell me suppose i insert 2 new records into my view_table when will this record get updated into my product_mv table.
    I cant use primary key approach so this is the approach i am following .Kindly help me in understanding when will refresh of records occur in the materialized view product_mv...Pls help
    regards
    debashis

    Hi Justin ,
    Yes, my database can reasonably schedule other jobs too .Its not an issue.
    Actually what i meant "fine in all aspects" is that will the matrerialized view will get refreshed w.r.t the documetum_v table present in my remote server.This is all i need to refresh my materialized view .
    I queries the DBA_JOBS table .I could see the following result i have pasted below:-
    [\n]
    NLS_ENV
    MISC_ENV INSTANCE
    dbms_refresh.refresh('"WORKFLOW"."PRODUCTS_MV2"');
    JOB LOG_USER PRIV_USER
    SCHEMA_USER LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE
    NEXT_SEC TOTAL_TIME B
    INTERVAL
    FAILURES
    WHAT
    [n]
    here WORKFLOW"."PRODUCTS_MV2 is the materialized view i have created.So can u tell me that whether we can predict our refresh part is functioning fine from this data.If so how?
    Actually i am asking u in details as i dont have much exposure to materialized view .I am using it for the very first time.
    Regds
    debashis

  • Help needed in converting Excel from XML file

    Hi Can anyone help me in converting XML in to Excel.
    Thanx,
    Ananth.

    well, that still isn't much to go off of. I give it a try though.
    I guess you want to parse out the relevent data out of the xml file and then decide on your favorite delimated file format for Excel. Two popular formats are comma delimated:
    "info1","info2","info3","info4"
    and tab delimeted:
    info <tab> info2 <tab> info3 <tab> info4
    Excel should be able to unsestand either of these formats.

  • Convert PDF to XML Format . Can´t get it working :(

    Hi everybody,
    I am a Rocky in Acrobat Scriptingand I need some helpd to convert a PDF file into an XML format using the build in javascript console.
    The only thing I got so far is:
    this.saveAs("/e/test.xml","com.adobe.acrobat.xml-1-00")
    I got this information from the refrence guide, but I did not find an accurate example. Can you lend me a hand ? If you find a solution can you also explain me the different sections of the code because I still want to learn something besides using the copy and paste option.
    Thank you very much:
    Roland

    Bernd Alheit wrote:
    What happens when you try it?
    The problem is I tried it several times, but nothing happens at all.  The reference guide mentioned a second file with the ending *.xls will be created but nothing happens at all. Can you help me out ?

  • Converting Javabeans into XML format

    HI,
    I have wrote program that will read input from users then stored them in javabeans. I used the serialize function to create xml file from the javabeans.
    public static void CreateXML(LocationRequest location)
              try
         // Serialize object into XML
         XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
    new FileOutputStream("test.xml")));
         encoder.writeObject(location);
         encoder.close();
         } catch (FileNotFoundException e) {
    The output file is as follows :
    <?xml version="1.0" encoding="UTF-8"?>
    <java version="1.4.1_05" class="java.beans.XMLDecoder">
    <object >
    <void property="address">
    <string>21212122</string>
    </void>
    <void property="originatorId">
    <string>Anu</string>
    </void>
    </object>
    </java>
    Could anyone has idea on how i can change the above xml file into another new xml format like below:-
    <address> 21212122</address>
    <originatorId> "Anu "</originatorId>
    Cheers,
    Bambli

    The quickest way would be to use XSLT. Write a stylesheet that converts your 1st format to your 2nd format.
    Here's an example stylesheet. (I'm a little rusty on my XSL so you'll want to test this.)
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" encoding="UTF-8"/>
      <!-- simply copy the message to the result tree -->
      <xsl:template match="/java/object/void/@property">
        <xsl:element name="local-name()">
          <xsl:value-of select="text()"/>
        </xsl:element>
      </xsl:template>
    </xsl:stylesheet> Feed this to a transformer as follows:
    javax.xml.transform.TranformFacotry factory = javax.xml.transform.TransformerFactory.newInstance();
    javax.xml.transform.stream.StreamSource source = new javax.xml.transform.stream.StreamSource(new java.io.File("yourstylesheet.xsl"));
    javax.xml.transform.Transformer xformer =factory.newTransformer(source);
    xformer.transform(new javax.xml.transform.stream.StreamSource(new java.io.File("yourbean.xml")),new javax.xml.transform.stream.StreamResult(new java.io.File("yourconverted.xml")));Its that simple.
    Cliff

  • How can I convert IDoc in XML format w/DTD into a string?

    I want to send by e-mail outbound IDoc in XML format with its document type definition (DTD).
    I want to be able to get the same output result into a string than the XML file IDoc port type with DTD activated.  I have created a FM (based on SAP "OWN_FUNCTION") assigned to an IDoc port of type ABAP-PI that executes the following processing steps:
    1-Extract outbound IDoc information to get the sender & recipient mail addresses (EDP13 / EDIPHONE tables).
    2-Convert & Transform IDoc data into XML string using FM IDX_IDOC_TO_XML.
    3-Prepare and send e-mail with XML attachement using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    I cand generate the e-mail with the XML file attachement but FM IDX_IDOC_TO_XML does not convert the IDoc with proper formating and DTD.
    What should I use to accomplish the IDoc conversion to XML w/DTD into a string?
    Should I use XSLT tools ?
    How does that work?
    Thank you
    Carl

    muks wrote:
    Use decimal string to number
    Specifically, you can define a constant with a different datatype on the input on the lower left if you need a different datatype (e.g. U8, I64, DBL, etc) Are all your values integers or do you also need to scan fractional numbers? In this case, you should use "fract/exp string to number" instead.
    LabVIEW Champion . Do more with less code and in less time .

  • Java Experts please help - SimpleDateFormat.format reduces date by a day !!

    Hi,
    I am facing a very weird problem with SimpleDateFormat class. The input Date to SimpleDateFormat.format method is getting reduced by ONE DAY. This problem is happening at random and is not reproducible at will. Any help/pointers to resolve this issue is very much appreciated !!.
    Code is similar to the following code lines
    input = "2003-11-01 00:00:00.000000000";
    output = 31-Oct-2003 (strange !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.text.DateFormatSymbols;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Hashtable;
    import java.util.Locale;
    import java.util.TimeZone;
    import java.util.SimpleTimeZone;
    public class DateTester {
    /** Default constructor for Util.
    public DateTester() {
    private static String replace(String pattern, String from, String to) {
    return replace(pattern, from, to, null);
    private static String replace(String pattern, String from, String to, String notFrom) {
    StringBuffer sb = new StringBuffer();
    boolean finished = false;
    int index = pattern.indexOf(from);
    if (index < 0) return pattern;
    do {
    if (notFrom == null ||
    notFrom.length() + index > pattern.length() ||
    !pattern.substring(index, index + notFrom.length()).equals(notFrom)) {
    sb.append(pattern.substring(0, index));
    sb.append(to);
    sb.append(pattern.substring(index + from.length()));
    finished = true;
    } else index = pattern.indexOf(from, index + from.length());
    while (!finished && index >= 0);
    if (!finished) return pattern;
    return sb.toString();
    public static void main(String[] argv) {
              String pattern = "DD-MON-YYYY";
    System.out.println("original pattern =" + pattern);
    pattern = replace(pattern, "FM", "");
    pattern = replace(pattern, "AD", "G");
    pattern = replace(pattern, "A.D.", "G");
    pattern = replace(pattern, "BC", "G");
    pattern = replace(pattern, "B.C.", "G");
    pattern = replace(pattern, "AM", "a");
    pattern = replace(pattern, "A.M.", "a");
    pattern = replace(pattern, "PM", "a");
    pattern = replace(pattern, "P.M.", "a");
    pattern = pattern.replace('\"', '\t');
    pattern = pattern.replace('\'', '\"');
    pattern = pattern.replace('\t', '\'');
    pattern = replace(pattern, "DDD", "DDD");
    pattern = replace(pattern, "DAY", "dd");
    pattern = replace(pattern, "DD", "dd", "DDD");
    pattern = replace(pattern, "HH24", "HH");
    pattern = replace(pattern, "HH12", "KK");
    pattern = replace(pattern, "IW", "ww");
    pattern = replace(pattern, "MI", "mm");
    pattern = replace(pattern, "MM", "MM", "MMM");
    pattern = replace(pattern, "MONTH", "MMMMM");
    pattern = replace(pattern, "MON", "MMM");
    pattern = replace(pattern, "SS", "ss");
    pattern = replace(pattern, "WW", "ww");
    pattern = replace(pattern, "W", "W");
    pattern = replace(pattern, "YYYY", "yyyy");
    pattern = replace(pattern, "YYY", "yyy");
    pattern = replace(pattern, "YY", "yy");
    pattern = replace(pattern, "Y", "y");
    pattern = replace(pattern, "RRRR", "yyyy");
    pattern = replace(pattern, "RRR", "yyy");
    pattern = replace(pattern, "RR", "yy");
    pattern = replace(pattern, "R", "y");
    System.out.println("converted pattern =" + pattern);
    String origDate = "2003-11-01 00:00:00.000000000";
    System.out.println("original date =" + origDate);
    Timestamp origTimeStamp = Timestamp.valueOf(origDate);
    SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.getDefault());
    sdf.setLenient(false);
    String formattedDate = sdf.format((Date) origTimeStamp);
    System.out.println("formatted date =" + formattedDate);
    Thanks a lot for your time !

    Your code is too hard to read for me to look at it in great detail. When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.
    However, I'm guessing it's a TimeZone issue. The midnight on 11/1 that you're setting is probably getting converted to GMT somewhere before the Date object is created. If you're in the U.S., then that's afternoon or evening on 10/31.
    Try:
    * Starting with a time that's later in the day on 11/1.
    * Formatting your date to include time and timezone when you print it. (Just for testing--you can put it back once you understand what's going on
    * Reading the Calendar, Timzone, Date, etc. APIs closely.
    * Reading any tutorials or texts you can find on the subject.
    * Writing a bunch of very small and simple tests to get an understanding of how this all fits together.
    Date/Time/TZ handling in Java is kinda tricky.

Maybe you are looking for

  • I don't want my flash menu to reload on every page

    Hi everyone, I have a website that I am working on where I have a menu made in flash, the menu expands when you select a category item and executes a hyperlink when you click on a particular item within the category. This hyperlink load a new page an

  • How Do I Keep "Find My Mac" Running in the Background Even When My MacPro is Closed?

    When I close my Macbook Pro and it goes to sleep it shuts off the "Find my Mac" feature, When I log into my icloud it doesnt find my Macbook. When I open the Macbook it shows up in iCloud again. My biggest fear is that someone could steal my Macbook

  • Java Russian Font

    I'm trying to write an application that takes a .txt file and parses the lines into a text area. The text file is saved in Unicode format and contains both russian and english characters. Currently, the application is reading the .txt file fine. I ha

  • Print command makes the programm to close

    I have recently bought a black macbook and when I use the print command (either from the menu or by pressing command and P) the programm (pages, preview, stickies, text, ms word) dissapears and a message that the programm quited unexpectedly appears.

  • Deploying EJB, JSF to soa suite application server

    Hello, I have a problem using EJB. I deployed my JSF page to my soa suite application server. But I think something is wrong between the communication of my page and the Bean. I keep getting the error : BO-29000: Unexpected exception caught: oracle.j