Where to modify code to format data

I am using BC4J and am pulling a date from the database. I want to just display the date in a custom format. Where do I do this at? This date will also be inputed by the user to insert into the database.
I am using Data Tags, but would prefer to use something more like UseBean tags.
TIA

I would like to do the same a Gerald. Has anyone created a custom tag that returns custom date format from BC4J. I actually am only viewing the date not actually inserting it back to the DB.
I know that this will be available in the next release but that is still a while away.
The code I am using is as follows:
<jbo:ShowValue datasource="TableName" dataitem="LastUpdTs" ></jbo:ShowValue>
null

Similar Messages

  • Error in outputting xml formatted data

    Hello,
    I'm trying to output xml formatted data using apex.
    At about 70% into the formatted output I get this in the browser:
      <descript>punct= & > < /,() &</descript>
      </row>
    - <row The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Only one top level element is allowed in an XML document. Error processing resource 'http://apex.oracle.com/pls/otn/f?p=158...
    <script language="JavaScript1.1" type="text/javascript">
    -^
    m">>
    <DIVI have a 600 row table (dml below) with identical string in each row of the descript column. (I put in some special characters just to push it through the escape function for html. It is displaying the text correctly.)
    The page has one report region (plsql below).
    The page template is stripped down.
    My local results are identical to the otn hosted workspace.
    I did dump the table in xml format and displayed the dump file in browser without a problem, so I'm missing something in the code.
    Thank you.
    Albert
    On OTN webspace, go to http://apex.oracle.com/pls/otn/f?p=15866:1:1291425545573680200:::::
    plsql
    declare
    xdescript varchar2(4000);
        begin
        -- xml preface is in the page template
        -- htp.p('<?xml version="1.0"?>');
        htp.p('<rowset>');
        begin
            for item in
            (select descript,cid from receipts order by cid)
            loop
            htp.p ('<row>');
            xdescript := htf.escape_sc(item.descript);
            htp.p('<cid>' || item.cid || '</cid>');
            htp.p('<descript>'|| xdescript || '</descript>');
            htp.p('</row>');
            end loop;
        end;
        htp.p ('</rowset>');
    end;
    dml
    CREATE TABLE  "RECEIPTS"
       (     "CID" NUMBER,
         "AMOUNT" NUMBER NOT NULL ENABLE,
         "CLEARED" DATE,
         "DESCRIPT" VARCHAR2(80),
         "DATEENTERED" DATE DEFAULT SYSTIMESTAMP,
         "CHECKNBR" NUMBER,
         "CLEARSEQ" NUMBER DEFAULT 0,
          CONSTRAINT "RECEIPTS_PK" PRIMARY KEY ("CID") ENABLE
    CREATE SEQUENCE   "RECEIPTS_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999
    INCREMENT BY 1 START WITH 4319 CACHE 20 NOORDER  NOCYCLE
    CREATE OR REPLACE TRIGGER  "BI_RECEIPTS"
      BEFORE INSERT ON "RECEIPTS"
      FOR EACH ROW
    BEGIN
        SELECT "RECEIPTS_SEQ".NEXTVAL INTO :NEW.CID FROM DUAL;
    END;
    ALTER TRIGGER  "BI_RECEIPTS" ENABLE
    /

    May be it helps you. I use SQL/XML and APEX Application Process to generate XML succesfully
    Here is the result:
    http://htmldb.oracle.com/pls/otn/f?p=9774:101:0:APPLICATION_PROCESS=RSSNEWEVENTS
    and here is the Process Text source:
    declare
    a clob;
    begin
    owa_util.mime_header( ccontent_type => 'text/xml', bclose_header => TRUE, ccharset => 'utf-8');
    htp.prn('<?xml version="1.0" encoding="UTF-8"?>');
    select
    XMLTYPE.getStringVal(
    XMLElement("rss",
    XMLAttributes('2.0' as version),
    XMLElement("channel",
    XMLConcat(
    XMLElement("title",'iActiveLife - novinky'),
    XMLElement("link",'http://www.iactivelife.cz/'),
    XMLElement("description",'iActiveLife - Zajímavý život snadn&#283;ji'),
    XMLElement("language",'cs'),
    XMLElement("pubdate",''),
    XMLAgg(
    XMLElement("item",
    XMLConcat(
    XMLElement("title",event_name),
    XMLElement("link",'http://htmldb.oracle.com/pls/otn/f?p=' || v('APP_ID') || ':37:' || v('SESSION') || '::NO::P37_EVENT_ID:' || event_id),
    XMLElement("description",'')
    ) into a
    from (
    select event_id,event_name,issue_date, last_update_order
    from (
    select events.event_id, events.event_name, events.issue_date, rank () over (order by events.issue_date desc) as last_update_order
    from events
    where exists ( select * from opportunities where events.event_id=opportunities.event_id and opportunities.user_id is not null)
    order by events.issue_date desc)
    where last_update_order<=10
    htp.prn(a);
    end;

  • Format Date function not working correctly

    Hi,
    I am using the following code to display a system date:
    <?xdofx:sysdate('DD-Month-YYYY')?>
    However the date always appears as:
    18-March -2011 (with space after 'March')
    rather than
    18-March-2011 (no space after the month)
    Can anyone tell me how to get the date to display without the space after the month?
    Thanks

    Some options:
    http://winrichman.blogspot.com/2008/08/xslt-extended-functions.html (right side screen shot)
    BI Publisher:formating date using xdofx
    Modify the output from current_date

  • Need Sample code to retrieve Data from Portal DB(Oracle)

    Would anyone provide me steps to create application with a sample code to retrieve data from portal DB which is oracle and see the output in table format.

    Hi Bris ,
    The sample code , you didnt specified from where do u want to access the oracle thorough java code or through webdynpro .
    Sample code to access through Java
    import java.sql.*;
    class Customer
    public static void main(String args[]) throws SQLException
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    System.out.println("Connecting to the database...");
    try
    Connection cn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","t");
    Statement st=cn.createStatement();
    ResultSet rs=st.executeQuery("select 'Connected' from dual");
    rs.next();
    String s=rs.getString(1);
    System.out.println(s);
    st.close();
    cn.close();
    catch(Exception ex)
    System.out.println("The exception raised is:" + ex);
    [code]
    If accessing through JDBC datasorce.
    https://www.sdn.sap.com/irj/sdn/thread?threadID=328550
    https://www.sdn.sap.com/irj/sdn/thread?threadID=309386
    [code]
    package com.dhl.employeemodel;
    import java.sql.Connection;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    public class DBConnectionManager {
         Connection connection;
          * @return
         public Connection getConnection() {
              try
                   Context jndiContext = new InitialContext();
                   DataSource ds = (DataSource)jndiContext.lookup("jdbc/MyAlias");
                   connection = ds.getConnection();
             catch(Exception connectionErrEx)
                   //connectionErrEx.printStackTrace();
                   return null;
              return connection;
    Thanx
    Pankaj

  • Formatted Data Labels in CFCHART

    Is there a way to format data values in CFCHART?
    All my values in database are stored as 99.9 See below). These are percentages that I need to display on a bar chart. Everything works fine except when displaying 76.0, it shows as 76. All other values that have a number besides zero after the decimal point show up fine except for zero. I want the numbers to be consistent. I am already using custom XML file for formatting but unable to display the "zero" after the decimal point.
    Let's assume, StartYear = 2007 and EndYear = 2008, and the data in Influencer_Data table looks like this:
    ID      Poll_Year     Company    Influence_ID      Pulse      Goal
    96      2008            XYZ            842                  59.6      59.6
    97      2008            XYZ            839                  80.8      80.8
    98      2008            XYZ            838                  86.9      86.9
    99      2008            XYZ            841                  67.1      67.1
    100    2008            XYZ            840                  66.3      66.3
    101    2008            XYZ            470                  54.5      54.5
    102    2007            XYZ            842                  56.5      56.5
    103    2007            XYZ            839                  81.5      81.5
    104    2007            XYZ            838                  85.5      85.5
    105    2007            XYZ            841                  71.2      71.2
    106    2007            XYZ            840                  76.0      76.0
    107    2007            XYZ            470                  54.2      54.2
    108    2008            XYZ            843                  82.6      82.6
    And the data in influencers table looks like this:
    Influencer_ID Influencer_Type
    470      Regulators
    838      Financial Community
    839      Community Leaders
    840      Media
    841      Government
    842      Advocates
    843      Mexico
    <cfloop index="i" from="#StartYear#" to="#EndYear#" step="1">
         <CFQUERY NAME="GetInfluenceData#i#" DATASOURCE="#RMIDSN#">
              Select     ID.*, I.Influencer_Type
              From     Influencer_Data ID
                   INNER JOIN Influencers I ON ID.Influencer_ID = I.Influencer_ID
              Where     ID.Poll_Year = <cfqueryparam value="#i#" cfsqltype="CF_SQL_INTEGER">
                   AND ID.Company = 'XYZ'
              Order     By I.Influencer_Type
         </CFQUERY>
    </cfloop>
    The custom XML file (TLRIS.xml) looks like this:
    ?xml version="1.0" encoding="UTF-8"?>
    <frameChart isInterpolated="false">
              <frame xDepth="4" yDepth="5" outline="black" isVGridVisible="true"/>
              <xAxis>
                   <labelFormat pattern="#0.0"/>
              </xAxis>
              <yAxis>
                   <labelFormat pattern="#0.0"/>
                   <labelStyle orientation="Horizontal"/>
              </yAxis>
              <dataLabels style="Value" font="Arial-12" isMultiline="true">
              <![CDATA[ $(value) ]]>
              </dataLabels>
              <legend allowSpan="true" equalCols="false" isMultiline="true"/>
              <elements drawOutline="false">
                   <morph morph="Grow"/>
              </elements>
              <popup decoration="Round"/>
              <paint palette="Fiesta" paint="Plain" isVertical="true" min="47" max="83"/>
              <insets right="5"/>
    </frameChart>
    And the code for the graph is below:
    <cfoutput>
    <cfchart format="#ChartType#"
         chartheight="300"
         chartwidth="750"
         scalefrom="0"
         scaleto="100"
         foregroundcolor="##000000"
         databackgroundcolor="##ffffff"
         font="Arial"
         fontsize="10"
         labelformat="number"
         style="TLRIS.xml"
         show3d="yes"
         showlegend="yes"
         tipstyle="mouseOver"
         tipbgcolor="##FFFF00">
         <cfloop index="i" from="#StartYear#" to="#EndYear#" step="1">
              <cfset LoopCount = LoopCount + 1>
              <cfset WhichColor = ListGetAt(colorlist, LoopCount)>
              <cfchartseries     
                          type="bar"
                         serieslabel="#i#"
                         seriescolor="#WhichColor#"
                         datalabelstyle="pattern">
                         <cfloop query="GetInfluenceData#i#">
                                    <cfchartdata item="#Influencer_Type#" value="#Pulse#">
                         </cfloop>
              </cfchartseries>
         </cfloop>
    </cfchart>
    </cfoutput>

    mohadi wrote:
    I have already done that with no success.
    I am beginning to believe this may be a bug.
    Even if you try something as simple as the following, the decimal points that have zeroes don't show
    <cfchart style="beige">
    <cfchartseries type="pie">
    <cfchartdata item="New car sales" value="50.0">
    <cfchartdata item="Used car sales" value="55.0">
    <cfchartdata item="Leasing" value="56.5">
    <cfchartdata item="Service" value="76.2">
    </cfchartseries>
    </cfchart>
    Well that is the wrong kind of chart and it is not using the xml style.  But it works perfectly with a bar chart, using a custom style. The values display exactly as you have them above.
    <cfchart style="myPatternStyle.xml">
        <cfchartseries type="bar">
            <cfchartdata item="New car sales" value="50.0">
            <cfchartdata item="Used car sales" value="55.0">
            <cfchartdata item="Leasing" value="56.5">
            <cfchartdata item="Service" value="76.2">
        </cfchartseries>
    </cfchart>
    <!--- snippet from xml styles --->
    .... other xml ....
    <yAxis scaleMin="0">
          <titleStyle font="Arial-12-bold"/>
          <dateTimeStyle majorUnit="Year" minorUnit="Month"/>
          <labelFormat style="Pattern" pattern="#,##0.0#######"/>
    </yAxis>
    .... other xml ....

  • Week returned by Format Date/time String

    Has anyone tested the Format Date/Time String function with the week formating codes?
    I want to create a subfolder for each week and name the folder accordingly. For 17 December 2003 the week is 51 in the year 03 but I get week 50. For 29 December 2003 the week is 01 in the year 04 but I get week 52. For 01 January 2004 the week is 01 in the year 04 but I get week 00. For 29 December 2004 the week is 53 in the year 04 but I get week 52. For 01 January 2005 the week is 53 in the year 04 but I get week 00. There is no difference using %U or %W as code (this will be if 1 January will fall on Sunday or Monday which it does not in my examples).
    I know normally a year has weeks 1 to 52 but in some years the last week may have week
    53 as in 2004. Adding 1 to the week does not solve the problem. For 29 December 2003 it would give 53. And 53 maybe a correct week as in 2004. For 1 January 2005 it would give 1 but the week is the week in the year before.
    All the week numbering I expect is correct for Germany but the function is not. Is the numbering from the function correct for your country?
    Please reply where you are located and if the function will work right for you.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

    I have found two resources about date and time and their formats.
    One is the ISO Standard 8601, the second is a german page. On this page along with other information all definitions used by Windows is listed.
    According to this page the ISO Standard has been established in Europe and most industrial countries. In USA it is ANSI X3.30-1985(R1991) and NIST FIPS 4-1.
    Since the ANSI definition you mentioned allows only Sunday (Jewish) or Monday (Christian) as first day of the week it ignores the Islamic world. For them the first day is Saturday. I could not gather information about Buddhistic or Hinduism
    based countries.
    For my application and the market aimed the ISO format is the one which will be choosen. Using %W and handling of week 0 should do it.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Where to put my customized formatting that Control Hints does not provide?

    To whom that know or have experience with it:
    The control hints does not provide solutions for all possible formatting needs. For example, I need to display only last four digits of social security numbers (i.e., for "123-45-6789", display "***-**-6789"). Another data table column stores school semesters as YYYYMM, e.g., 200902, where 2009 is the year and 02 is the month that represents Spring (MM can also be 06 and 09 that represent Summer and Fall). I need to display the semester in a more user-friendly way (i.e., for "200902", display "Spring 2009"). Of course, I can not change data format in the table; I only seek to format the display of the data.
    I would think that it takes only a few lines of java code to do these formatting by splitting the string into sub-strings, replace some of them with appropriate new values, then re-assemble them. But where to put such code? Does any documentation cover this topic?
    Newman

    Shay,
    I read the document, tried it, and it worked out nicely.
    There is not the getAttributeName() method in the ViewObjectImpl class in version 10.1.3.4, which is the version I am using. But the EO class has it and it works out all the same.
    I don't know how long it would otherwise take me to read and fumble to find out where to put the custom formatting code. Your experience and familiarity with the technology really saved me a huge amount of time. Thank you so much for your help!
    Newman

  • How to print formatted data / report on user's printer in Web Application

    Hi All
    I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
    application is web based and tech. used are Java - jsp - servlets
    now prob. is ...
    how i will transfer all data to client (web browser) from the server and how i can print that data on user's printer ...??
    there is requirement that I can not use applet for this purpose.
    if any one done or have idea then let me know.
    thanks
    Shailesh Koradiya

    Hi
    Its simple, first of all break ur data in terms of pages. Write the logic in one JSP.
    suppose i have jsp PrintReport.jsp , for page 1 url will PrintReport.jsp?page=0 ... so on
    get the page parameter in JSP
    String page="";
    if(request.getParameter("page")!=null)
    page=request.getParameter("page");
    get the rowcount from the Result and assume records per page is 100
    if u have 1000 rows then 10 pages u have to serve
    StartRowNumber=page*recordsPerPage
    EndRowNumber=StartRowNumber+recordsPerPage
    Execute a SQL query , select * from table where rownum between
    StartRowNumber and EndRowNumber
    Provide google like pageNumbers in ur HTML page
    ie 1 2 3 4 5 6 ..10
    Regarding printing , Create HTML button called 'print' and add Javascript ' window.print()' on clicking it.
    Hope it would solve ur problem
    Cheers
    Rajendra Bandi

  • How to format dates in SQLExec query

    I am trying to archive Lookout data to an Oracle database using SQLExec. I started with existing SQLExec code that put data into Access. Following is that code:
    "Insert into wind_temp (Rdate,Wind,Temp) values ("&text(now(Timer3),"0.00000000")&",
    "&text(\\SCADA1\Server\Drivers\Corral\ROCSouth.Wind,"0.000")&",
    "&text(\\SCADA1\Server\Drivers\Corral\ROCSouth.Temp,"0.000")&")", 8, no);
    The Rdate column in wind_temp table is date type. If I change the type to varchar2 (string) this works, so my ODBC connection is good. The problem is that for date fields Oracle needs a string in DD-MON-YYYY (i.e. 01-JAN-2002) format or string data converted to a date (i.e. to_date('01-JAN-2002 12:00:00','DD-MON-YYYY HH24:MIS')). Is there a way
    using the now() or other function to build a "to_date" string like above to pass to Oracle?

    Here you go:
    text(now(),"dd/mm/yyyy hh:mm:ss")
    This will give you slashes and not dashes and a number for the month and not the abbreviated name.
    Here is the expansion that does what you need:
    left(text(now(),"dd/mm/yyyy hh:mm:ss"),2)&"-"&if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="01","JAN",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="02","FEB",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="03","MAR",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="04","APR",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="05","MAY",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="06","JUN",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="07","JUL",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="08","AUG",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="09","SEP",if(m
    id(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="10","OCT",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="11","NOV",if(mid(text(now(),"dd/mm/yyyy hh:mm:ss"),4,2)="12","DEC","ERROR"))))))))))))&"-"&mid(text(now(),"dd/mm/yyyy hh:mm:ss"),7,15)
    The date I got from this was:
    11-APR-2002 11:54:35
    I would recommend using multiple expression objects to simplify reading the code. I included it here, all in one expression, so you could copy and paste it for testing.
    I tested it on Lookout 5.0. It works.
    Study the text() function and the general text manipulation functions. You can do just about anything with a little creativity.
    Regards,
    Tommy Scharmann

  • FM code for extracting data from 10 tables

    Hi All,
    I have a requirement, where i need to extract the data from 10 tables using FM which is further used to create a data source in SAP R3.
    The fields are almost similar in all the tables but yet i have to fetch the data from all the tables.
    My approach:
    1. I have created a structure with all the fields in it from all the tables that comes to 35 fields.
    2. create a structure of each table and loop it into an internal table and work area.
    3. writing a read statement based on a key value from all the work areas and populate the same into my final structure.
    Note: there is a key field that need to be considered when updating the data into final stucture.
    All help on the code / logic would be appreciated.
    Thanks
    Moderator message : Spec/requirements dumping not allowed, show the work you have already done.  Thread locked.
    Edited by: Vinod Kumar on Feb 28, 2012 8:35 PM

    Hi All,
    I have a requirement, where i need to extract the data from 10 tables using FM which is further used to create a data source in SAP R3.
    The fields are almost similar in all the tables but yet i have to fetch the data from all the tables.
    My approach:
    1. I have created a structure with all the fields in it from all the tables that comes to 35 fields.
    2. create a structure of each table and loop it into an internal table and work area.
    3. writing a read statement based on a key value from all the work areas and populate the same into my final structure.
    Note: there is a key field that need to be considered when updating the data into final stucture.
    All help on the code / logic would be appreciated.
    Thanks
    Moderator message : Spec/requirements dumping not allowed, show the work you have already done.  Thread locked.
    Edited by: Vinod Kumar on Feb 28, 2012 8:35 PM

  • How to use many format data into a template?

    How to design a template but it can interface from many format data? 

    This is the one from 2010 but should still work.
    http://www.bfcnetworks.com/blogs/alexpearce/pull-sharepoint-2010-document-properties-into-word-quick-parts/
     You basically create a new document in the library (must have the columns you want into the word document), then you use the Quick
    Parts to insert the data where needed. Then you save this document as your template. Then anytime someone creates a document in the library when you open the document it will read from the columns of the item.
    I used a workflow and had the users actually update a SharePoint list, then that in turn creates a new document in the document library and populate the columns from the list form. Then You can send that document link to folks to download / print or whatever.
    Is that what you are talking about?

  • Formatting dates in a table in webdynpro java for mutliple entries.

    Hi all,
    I have a requirement to format date values in a table for multiple entries to dd/MM/yyyy format in webdynpro java for mutiple line items in that table.
    Please help me out with the technique for the same.
    Thanks and Regards,
    Soumyadeep.

    Hi,
    here is the code for changing the formatting the date.
    Date currentDate = new Date ();
                DateFormat df =  DateFormat.getDateInstance(DateFormat.SHORT);
                String today = df.format(currentDate);
                SimpleDateFormat sdfInput = new SimpleDateFormat("dd/mm/yyyy");
                SimpleDateFormat sdfOutput = new SimpleDateFormat ("mm/dd/yyyy");
    try {
                      String dateft = sdfOutput.format((Date) sdfInput.parse(df.format(currentDate)));
                } catch (ParseException e) {

  • Issue with format: date dd-MMM-yyyy - First letter lower instead of capital

    Hi colleagues,
    I am facing a problem using: <?format-date:FIELD_NAME;’dd-MMM-yyyy’;'UTC'?> on my RTF template.
    When the report run on English it retrieves: Apr, Jun, ...
    but in French it retrieves: apr, jun.
    The client wants the first letter of the month in capital letter I thought that MMM is the format to manage it...
    I am using XML Publisher with PeopleSoft.
    The template is in French and using bursting I create the report in different language depending on some parameters.
    When I preview the template everything is ok.
    Does anyone knows where is the Abbreviate Name of the Month comes from?
    Thanks in advance,
    Juan Diego

    Hi Juan
    It ought to be returning 'Arv' not 'apr' in French right?
    It might be an issue with the i18n library that is being shipped. I would suggest logging a service request with support for some help.
    Regards
    tim

  • Problem formatting date.

    I have a problem in validating and formatting date input by the user. The user input format is dd-MM-yyyy. I have to validate it and format it to dd-MMM-yy format. I tried the below code.
    import java.util.*;
    import java.text.*;
    public class DateFormatter{
         public static void main(String[] args){
              String str = "24-12-20gg";
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              try{
                   sdf.setLenient(false);
                   Date date = sdf.parse(str);
                   System.out.println(date);
              }catch(Exception e){
                   System.out.println(e);
    The above code parses the date as - Tue Dec 24 00:00:00 IST 0020 . I want to throw an exception if it is not a date and is not of four digits. Any solution ?.

    Why not Java support such things. This will help to avoid reinventing the
    wheel.Java does support such things; there is no need to reinvent the wheel. Example:
    import java.text.*;
    import java.util.*;
    public class DateParseDemo {
        public static void main(String[] args) {
            new DateParseDemo().go();
        public void go() {
            String format = "dd-MM-yyyy";
            String goodDate = "24-12-2003";
            String badDate = "Dec 24, 2004";
            if (dateIsValid(format, goodDate)) {
                System.out.println("\"" + goodDate + "\" is valid!");
            if (!dateIsValid(format, badDate)) {
                System.out.println("\"" + badDate + "\" is NOT valid!");
        public boolean dateIsValid(String format, String date) {
            boolean valid = false;
            DateFormat df = new SimpleDateFormat(format);
            Date parsed;
            try {
                parsed = df.parse(date);
                valid = true;
            } catch (ParseException pe) {
                // log exception
            return valid;

  • Formatting data in table - jsp & jdbc

    Hey there friends!
    I was having a little problem formatting data and I was looking for help!
    I want to format the data from jdbc as follows on a jsp page
    THIS IS REPORT TO GENERATE
    Name | Worked | Refused | Training | CarryOver
    Jim | 10 | 5 | 2 | 5
    Bob | 20 | 5 | 10 |
    The resultset that I retrieve from my database is like this
    RESULTSET
    ID | Name | Type | Hours | CarryOver
    1 | Jim | Worked | 10 | 5
    1 | Jim | Refused | 5 | 5
    1 | Jim | Training | 10 | 5
    2 | Bob | Worked | 20 | 10
    2 | Bob | Training | 5 | 10
    Can anyone suggest what can be a done here?

    As you have learnt something it is only fair for me for reciprocate.
    The code example I gave you was psuedocode - not real java. You need to add in a couple more things to make it work correctly.
    First we want to create an entry in the hash, iff there is no record already there, otherwise, we want to get the value and add our new value to it (let's say the map is called map):
    String key = record.name + "/" + record.type;  // Using combination string as the key - simplest solution
    Long hours = map.get(key);
    if (hours == null) {
       hours = new Long(record.hours);
    } else {
       hours = new Long(hours.getValue() + record.hours);
    map.put(key, hours);It would be better to use your own class to hold the long value - as this would save all the construction calls.

Maybe you are looking for