Nvl for data picker

My report is based on two data picker items. If the value is not chose for the items, then I specify their value using nvl .
like this
select .......
from.......
where ....
and
hiredate >= NVL(TO_DATE(:P4_START_DATE,'DD-MON-YYYY'),date '2009-01-01')
AND
hiredate <= NVL(TO_DATE(:P4_END_DATE,'DD-MON-YYYY'),date '2010-03-31')
But I get the error that day must be between 1st and last day of the month.
I get error even if I use
select .......
from.......
where ....
and
hiredate BETWEEN NVL(TO_DATE(:P4_START_DATE,'DD-MON-YYYY'),date '2009-01-01')
AND NVL(TO_DATE(:P4_END_DATE,'DD-MON-YYYY'),date '2010-03-31')
Please help me out!

Error message means that somewhere day number is wrong
select to_date('32-02-2010','dd-mm-yyyy') from dual; or
select to_date('00-02-2010','dd-mm-yyyy') from dual; 1)What is the value of :P4_START_DATE when you get this error?
2) Check your current NLS settings - try
select to_char(sysdate,'dd-mon-yyyy') from dual2)What is the type of hiredate column?
3)Try to replace :P4_START_DATE with 01-04-2010 - run :
select .......
from.......
where ....
and
hiredate >= NVL(TO_DATE('01-APR-2010','DD-MM-YYYY'),to_date('2009-01-01','yyyy-mm-dd'))
AND
hiredate <= NVL(TO_DATE('01-APR-2010','DD-MM-YYYY'),to_date('2010-03-31','yyyy-mm-dd'))Could the error be in the other part of the query?
try:
select .......
from.......
where ....
and
hiredate >= NVL(TO_DATE('01-APR-2010','DD-MM-YYYY'),to_date('2009-01-01','yyyy-mm-dd'))
AND
hiredate <= NVL(TO_DATE('01-APR-2010','DD-MM-YYYY'),to_date('2010-03-31','yyyy-mm-dd'))
*/

Similar Messages

  • Unable to set default date for Date Picker item using Auto Row Processing

    Okay, I have searched through the forum for an answer, and have not found a thing to account for my problem.
    First, does anyone know if using Auto Row Processing has problems updating an item/field in a record where the Source is defined as Database Column if the 'Display As' is defined as 'Date Picker (MM/DD/YYYY)'?
    I ask this only because I found out the hard way that Auto Row Processing does NOT fetch the value for an item where the field is defined as TIMESTAMP in the database.
    My problem is as follows: I have a form that will CREATE a new record, allowing the user to select dates from Date Pickers, text from Select Lists, and entering in text into a Textarea item. The information is saved using a standard (created through the Auto Row Processing wizared) CREATE page level button. After the record is created the user is able to go into it and update the information. At that time, or later, they will click on one of two buttons, 'ACCEPT' or 'DECLINE'. These are Item level buttons, which set the REQUEST value to 'APPLY' (Accept) and 'UPDATE' (Decline). The Accept button executes a Process that changes the Status Code from 'Initiated' to 'Accepted', and sets the Declined_Accepted_Date to SYSDATE, then another Process SAVEs the record. The Declined button runs a Process that changes the Status Code from 'Initiated' to 'Declined', and sets the Declined_Accepted_Date to SYSDATE, then another Process SAVEs the record.
    However, even though the Status Code field is updated in the database record in both Accepted and Declined processing, the Declined_Accepted_Date field remains NULL in the database record (by looking at the records via SQL Developer). WHY??? I looked at the Session State values for both the Status Code and the Declined_Accepted_Date fields and saw that the fields (items) had the expected values after the process that SAVEs the record.
    The following is the code from the Accept button Page Process Source/Process:
    BEGIN
    :P205_STATUS_CD := 'A';
    :P205_REF_DECLINE_ACCEPT_DT := SYSDATE;
    END;
    As can be seen, the Status Code and Declined_Accepted_Date items are set one right after the other.
    As an aside, just what is the difference between Temporary Session State vs Permanent Session State? And what is the sequence of events to differentiate the two?

    Here's yet another thing that I just looked into, further information...
    One other difference between the date field I am having problems with (Accepted_Declined_Date), and other dates (with Date Pickers) in the record is that the Accepted_Declined_Date never gets displayed until after it is set with a default date when the Accept and Decline buttons are pressed.
    One of the other dates that works, the Received Date, is able to write a default date to the record that is never typed into the box or selected from the calendar. That date is placed into the box via a Post Calculation Computation in the Source, which I set up as: NVL(:P205_REF_RECEIVED_DT,TO_CHAR(SYSDATE,'MM/DD/YYYY'))
    However, I do remember actually trying this also with the Accepted_Declined_Date, and setting the Post Calculation Computation did not work for the Accept_Decline_Date. Could this be because the Accept_Decline_Date is never rendered until the Status Code is set to Declined (in other words, there is no need to display the date and allow the user to change it until the record is actually declined)???
    The control of the displaying (rendering) of the date is set via the Conditions / Condition Type: Value of Item in Expression 1 = Expression 2
    Expression 1 = P205_STATUS_CD and Expression 2 = L
    Does this shed any light???

  • SQL query for date picker

    On a reports page there are two 2 date picker items ( a datefrom and a dateto) along with a text field with autocomplete item
    When the page loads the following query is called
    SELECT
    "COL1",
    "COL2",
    "COL3",
    from "TABLE"
    WHERE MYDATES BETWEEN :DATEFROM AND :DATETO
    Which returns no records as no dates have been selected.
    How can I alter this so the WHERE clause on the date item searches is called only if and when the dates are chosen, and by default all records are shown.
    The other related issue is when I have selected a from and to date and search when I go back into the report view page after viewing other pages in the apex app, the form fields are still populated, how can I clear the session down for these fields when the user leaves the page?
    Hope this all makes sense?

    To_date('01.01.2100', 'dd.mm.yyyy') is going to give wrong results on 02.01.2100 :D
    A solution (maybe there is a cleaner one...) :
    WHERE
    ((:DATEFROM IS NOT NULL AND mydates >= :DATEFROM) OR :DATEFROM IS NULL)
    AND
    ((:DATETO IS NOT NULL AND mydates <= :DATETO) OR :DATETO IS NULL)You can change the "No data found" message by modifiying the "When No Data Found Message" report attribute.
    EDIT : And for the 2nd issue, Alex is right, but also be aware that Firefox retains form element values on page refresh, you have to switch the "Form Auto Complete" page security attribute to "Off" if you don't want to retain form element values.
    Edited by: Yann39 on 27 juin 2012 06:30

  • Using NVL for date

    I am creating a view and one of the columns is this:
    (b.startdate || ' To ' || b.enddate) salesDateRange
    however when I was trying to handle the null value of date, I found the following problems,
    case 1
    (nvl(b.startdate, 'NA') || ' To ' || b.enddate) salesDateRange
    when i use nvl, I am able to create the view, but when I retrieve the data, I get this error msg.
    ORA-01858: a non-numeric character was found where a numeric was expected
    01858. 00000 - "a non-numeric character was found where a numeric was expected"
    *Cause:    The input data to be converted using a date format model was
    incorrect. The input data did not contain a number where a number was
    required by the format model.
    *Action:   Fix the input data or the date format model to make sure the
    elements match in number and type. Then retry the operation.
    is nvl only available for numerical value?

    user8944947 wrote:
    I am creating a view and one of the columns is this:
    (b.startdate || ' To ' || b.enddate) salesDateRange
    however when I was trying to handle the null value of date, I found the following problems,
    case 1
    (nvl(b.startdate, 'NA') || ' To ' || b.enddate) salesDateRange
    when i use nvl, I am able to create the view, but when I retrieve the data, I get this error msg.
    ORA-01858: a non-numeric character was found where a numeric was expected
    01858. 00000 - "a non-numeric character was found where a numeric was expected"
    *Cause:    The input data to be converted using a date format model was
    incorrect. The input data did not contain a number where a number was
    required by the format model.
    *Action:   Fix the input data or the date format model to make sure the
    elements match in number and type. Then retry the operation.
    is nvl only available for numerical value?In addition to the answers already given, you have to consider that NVL is an overloaded function, designed to deal with different datatypes. It accepts 2 arguments and the version of NVL that is used depends on the arguments given (that's the nature of overloading - look it up on the internet if you're not sure).
    So, there is defined e.g.
    NVL({noformat}<number arg>, <number arg>{noformat})
    NVL({noformat}<varchar2 arg>, <varchar2 arg>{noformat})
    NVL({noformat}<date arg>, <date arg>{noformat})
    etc.In your example, as the first argument you are passing in is a date, Oracle is opting to use:
    NVL({noformat}<date arg>, <date arg>{noformat})But your second argument is not a date, it's a varchar2.
    However, Oracle is clever and can perform "implicit" conversions between datatypes i.e. it will try and convert datatypes without you actually telling it to. (It's generally good coding practice to do it yourself though).
    So, in you case Oracle is taking your varchar2 string "NA" and trying to implicitly convert this to a date, using the only way it knows how, which is to apply a date format mask as defined by the NLS_DATE_FORMAT parameter for the session. For example, internally it will be trying to do the equivalent of:
    TO_DATE('NA','DD-MON-YYYY')(assuming your NLS_DATE_FORMAT parameter is set to DD-MON-YYYY)
    If we try that ourselves, we get...
    SQL> select to_date('NA','DD-MON-YYYY') from dual;
    select to_date('NA','DD-MON-YYYY') from dual
    ERROR at line 1:
    ORA-01858: a non-numeric character was found where a numeric was expected... which is the same error you were getting.
    So, in order for your NVL to work you would either need to supply a DATE as the second argument (some default date to use if the first argument is null), or some varchar2 string that represents a date in the correct format as per your NLS_DATE_FORMAT setting (dangerous because if the NLS_ setting changes then your code can suddently error), or you provide the first argument as a VARCHAR2 string instead of a date (using TO_CHAR), so the the function overloading causes Oracle to choose the varchar2 argument version of NVL, for which 'NA' is a perfectly valid second argument.

  • Access denied for Date Picker Control in sitepage

    We have an issue with Date Picker controls in a web page.
    Two date Picker controls were added to one site page to allow users to enter start date and end date to search. The controls are placed in the ContentPlaceHolder web part. The controls allow user to pick a date at Dev, SIT, and Prod environment but not working
    in UAT.
    At UAT, an Access Denied error message appears when the Date Picker control is clicked.
    Feng Wan

    Hello,
    What permission is user having on page? Have your tried with different account with higher permission?
    You can also look at this blog if this is the case:
    http://sharepointwings.blogspot.sg/2013/08/sharepointdatetimecontrol-access-denied.html
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Any way to set StartDayOfWeek for Date Picker in af:inputDate

    In af:inputDate, First Day of Week varies in different locales, is there any way the Date Picker can show it correctly without formatting-locale?

    af:inputDate should do this automatically based on the browser's locale setting. Can you describe your use case in more detail where this is not the desired behavior?

  • Code for Date Picker

    Hi all,
      I have a icon related to calendar.when the mouse is over the icon it should open the calendar and when i click the particular date it should automatically enter into the input fields.
    Thanks In Advance.
    Regards,
    Surya.

    Hi,
    You can use the htmlb:dateNavigator tag for it. Check the tag browser, BSP extensions, Transportable, HTML. Drag the tag on the layout, click on the tag and press F1 for help.
    Alternatively, you can use things like the Tigra calendar: http://www.softcomplex.com/products/tigra_calendar/
    Eddy
    PS.
    Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
    Spread the wor(l)d!

  • "Date picker" in report - - View source shows no label for the date picker

    Hi
    In one of my reports, I am using multiple types (textarea/text/date picker/select list)
    I wanted to use a javascript based on the label, but I do not see "<label>" for Date picker in the view source due to which my Javascript fails.
    Snippet of view Source:
    <td class="t3data" ><label for="f08_0001" class="hideMe508">CATEGORY</label><textarea name="f08" rows="4" cols="16" wrap="VIRTUAL" id="f08_0001">EMPLOYEE INDUCTION</textarea></td>
    <td class="t3data" ><span class="lov"><input type="text" name="f11" size="15" maxlength="2000" value="29-FEB-08" style="padding-right:5px;" id="f11_0001" /><script type="text/javascript">
    As you can see above, we have a "label for" for the text area but not for the date picker
    Is there a reason for the same?
    Thanks
    Nitin

    Hi,
    OK - the headers attribute should also help as these will identify the correct cells. You would need to know the html tags used within each cell for each datatype.
    Would using cloneNode help you? It's a method of creating a copy of an entire row in a single instruction
    Andy

  • Date Picker problem in Apex 3.1

    Hi,
    I upgraded my apex to 3.1 and found that the date picker icon behaviour become quite strange.
    If I set the label of the date picker Horizontal/Vertical Alignment to Above, the picker icon will show below the text box instead of right side. And the pop-up calendar for Date Picker (DD-MM-YYYY HH24:MI) also not high enought to show the Close and OK button, I have to manually adjust the pop-up calendar height.
    All this problems were not there in 3.01, is these some kind of bug?
    Thanks
    Vincent

    Hello,
    Can you put an example of your particular layout on apex.oracle.com. The solution I had worked in most of the case's I tested , obviously yours is different.
    The next best solution would be to either shim the items with images, or to specifically set the widths of the containing table cells.
    The reason all this is happening is sometimes , depending on the region templates and CSS the regions will collapse down on the content, and the the browsers will do there best to fit the content in the smallest place possible, Unfortunately, in some cases the browsers ignore both nowrap="nowrap" and/or style="white-space:nowrap", why would I want to put nowrap on something and still have it wrap, I don't know it's not me it's the browsers.
    The solution in the patch I'm leaning towards is wrap item into a table. As it will work perfectly everywhere , and greatly annoy people that want tableless layouts, but that won't be available till the patch.
    Regards,
    Carl
    blog : http://carlback.blogspot.com/
    apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

  • How to Change UI element from input Field to Date Picker

    Hi All,
    One Custom View is created in which we are pulling some fields from a custom context node created using the value Node.
    For one of the field which is already an input field we need to convert it to date picker.
    in the GET_P_METHOD
    CASE IV_PROPERTY.
    WHEN 'fieldType'.
    rv_value = cl_bsp_dlc_view_descriptor=>field_type_radio.
    WHEN 'radioCols'.
    rv_value = '1'.
    ENDCASE.
    We can change the attribute to clbsp_dlc_view_descriptor_ and bring
    checkbox,radiobutton,hyperlink and all but not finding anything for Date picker.
    Can anyone suggest a method by which we can convert a UI element to Date Picker.
    Any suggestions will be highly appreciated.
    Regards,
    Sijo

    The technical data type for that field should be DATS then input help will automatically come.
    Also in get_m method of that attribute should have
      metadata = cl_crm_uiu_bt_date_tools=>get_m_date( ir_model_binding  = me
                                                      iv_attribute_path = attribute_path ).
    Regards,
    Shobhit

  • Date picker default value

    No matter what I put in the default value for date picker none will show up.
    I used these:
    TO_DATE(CURRENT_TIMESTAMP,'DD-MON-YYYY HH:MIPM')
    TO_CHAR(CURRENT_TIMESTAMP,'DD-MON-YYYY HH:MIPM')
    CURRENT_TIMESTAMP
    :CURRENT_TIMESTAMP
    Any Help?
    Thanks,

    Hi,
    Have you specified what type of default value it is? Static Text, PL/SQL Expression or PL/SQL Function Body?
    I have that the best way to set a default value is by creating a computation, set to run Before Header and conditional on the item being NULL.
    Andy

  • How to change date picker display format?

    Default display format is 01-JAN-09 for date picker.
    How can I change it to
    Jan 21, 2009
    Thank you.

    If you need use your format for all data pickers in your application you can set it via:
    Go to
    Shared components ->Definition->Globalization (Tab) -> Application Date Format SET to Mon DD,YYYY
    and in the item Display as set "Data Picker (use ppplication format mask)"
    If you need set format to some data picker you have to go to your data picker item and Display as set "Data Picker (use item format mask)"
    and
    Go to Source region in this item and set Format mask field Mon DD,YYYY

  • Date Picker - show specific month of perticaular year

    Hi Experts,
    I am using sam.m.DatePicker control. By default date picker show current month-year when user open date picker. I want to show specific month of specific year when date picker is open.
    for eg: In my app, if student appearing for next year exam(say 2016) then when he click on date picker it should show April of 2016 instead of april of 2015. I don't want to set date by default. Student should select that date manually.
    Is it possible to show specific month and year for date picker when it open.
    Thanks in advanced.

    Hi,
    you can also give a default date of the first date of that month.
    Why you are not using that?
    var datePicker = new sap.m.DatePicker({
                                            valueFormat: "yyyy-MM-dd",
                                            displayFormat: "long",
                                                   value: "2014-03-26"
    Regards
    Dhananjay

  • Date Picker with seconds?

    Hi everybody,
    In my APEX application, for a particular form element, I need to setup a date picker with date + time with seconds.
    Unfortunately, in the differents masks that can be used for date picker element, there is not support of seconds.
    I have tried to set the default date format at "DD/MON/YYYY HH24:MI:SS" for my application, then to choose the date picker based on the application default date format, but still no support for seconds, only hour and minutes...
    Does anyone have an idea about that issue, and a way to implement seconds in my date picker? The point is that I need to be able to select the exact second in a range.
    Maybe something with jQuery or something else?
    Any help much appreciated!
    Thanks,
    Romain.

    Yes, this is one of the solutions, but of course it will require to create these additional elements...
    Still looking for an "all-in-one" way. If nothing is possible on the date picker level, I will manage it with more elements.
    Thanks,
    Romain.

  • Date picker for af:inputDate   is not picking up the correct input date

    view source:
    <af:inputDate value="#{bindings.DateField.attributeValue}" label="#{bindings.DateField.hints.label}"
    required="#{bindings.DateField.hints.mandatory}"
    valueChangeListener="#{pageFlowScope.CollectApplicantInformation.datesItemChanged}"
    columns="#{bindings.DateField.hints.displayWidth}" shortDesc="#{CustomTooltip[DateField]}"
    autoSubmit="true" helpTopicId="AppDt" id="DateField" simple="true">
    <f:validator binding="#{bindings.DateField.validator}"/>
    *<f:converter converterId="CustomConverter"/>*
    </af:inputDate>
    Here I am not using <af:ConvertDateTime> insted using customConverter, so what code changes do I need to make sure the date picker always picks the already existind date in the inputDate rather picking the current date?
    Here is my CustomConverter.java
    CustomConverter.java
    public class CustomConverter extends DateTimeConverter implements ClientConverter, Converter
    public Object getAsObject(FacesContext context, UIComponent component, String value)
    String dataType = (String) resolveExpression("#{bindings." + component.getId() + ".attributeDef.javaType.name}");
    if (dataType != null && !dataType.equalsIgnoreCase("oracle.jbo.domain.Date") && !dataType.equalsIgnoreCase("oracle.jbo.domain.Timestamp"))
    String test = null;
    if (context == null || component == null)
    throw new NullPointerException();
    if (value != null)
    // To solve DB transaction dirty issue, Check isEmpty and return null.
    if (value.isEmpty())
    return null;
    // the "value" is stored on the value property of the component.
    // The Unified EL allows us to check the type
    ValueExpression expression = component.getValueExpression("value");
    if (expression != null)
    Class<?> expectedType = expression.getType(context.getELContext());
    if (expectedType != null)
    System.out.println("expectedType Value:::" + expectedType.getName());
    // try to convert the value (Object) to the TYPE of the "value" property
    // of the underlying JSF component
    try
    return TypeFactory.getInstance(expectedType, value);
    catch (DataCreationException e)
    String errorMessage;
    if (expectedType.equals(CustomNumber.class))
    errorMessage = "You can enter only Numbers in this field";
    else
    errorMessage = e.getMessage();
    if (errorMessage != null)
    FacesContext ctx = FacesContext.getCurrentInstance();
    FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid Format" , errorMessage);
    ctx.addMessage(component.getClientId(), fm);
    catch (CustomDomainException e)
    int errorCode = e.getErrorMessageCode();
    String[] errorMessage = e.getErrorMessageParams();
    if (errorCode == 7 && errorMessage != null)
    String msg = "Invalid " + errorMessage[0];
    FacesContext ctx = FacesContext.getCurrentInstance();
    FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Application Error: ", msg);
    ctx.addMessage(component.getClientId(), fm);
    catch (JboException e)
    Throwable cause = e.getCause();
    if (cause == null)
    cause = e;
    test = "not good format";
    throw e;
    return null;
    else
    return value != null? value: null;
    public String getAsString(FacesContext context, UIComponent component, Object value)
    return value != null? value.toString(): null;
    public String getClientLibrarySource(FacesContext context)
    return null;
    @Override
    public Collection<String> getClientImportNames()
    return Collections.emptySet();
    @Override
    public String getClientScript(FacesContext context, UIComponent component)
    String formatMask = (String) resolveExpression("#{bindings." + component.getId() + ".format}");
    if (formatMask != null)
    String dataType = (String) resolveExpression("#{bindings." + component.getId() + ".attributeDef.javaType.name}");
    if (dataType.equalsIgnoreCase("oracle.jbo.domain.Date") || dataType.equalsIgnoreCase("oracle.jbo.domain.Timestamp"))
    if (component == null)
    _LOG.severe("The component is null, but it is needed for the client id, so no script written");
    return null;
    // Add a JavaScript Object to store the datefield formats
    // on the client-side. We currently store the format string
    // for each and every field. It'd be more efficient to have
    // an array of formats, then store for each field the
    // index of the format, especially if we could delay outputting
    // these objects to when the <form> closes.
    String clientId = component.getClientId(context);
    if (clientId != null)
    // =-=AEW Only if Javascript...
    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
    // this fetch could be at the place where we append, but has been
    // moved ahead to optimize use of StringBuilder
    String jsPattern = getJSPattern(context, component);
    String loc = _getLocaleString(context);
    // FIX - figure out size!!!
    // 127 chars for javascript + length of jspattern + locale + 12 chars for
    // tranforming to name in the worst case.
    StringBuilder buff = new StringBuilder(139 + jsPattern.length() + loc.length());
    if (requestMap.get(_PATTERN_WRITTEN_KEY) == null)
    requestMap.put(_PATTERN_WRITTEN_KEY, Boolean.TRUE);
    // only create the _dfs object if it doesn't exist, so we don't
    // wipe out _dfs[xxx] values if we ppr the first date field on a
    // page with multiple date fields.
    buff.append("if(window['_dfs'] == undefined){var _dfs=new Object();}if(window['_dl'] == undefined){var _dl=new Object();}");
    buff.append("_dfs[\"");
    buff.append(clientId);
    buff.append("\"]=");
    buff.append(jsPattern);
    buff.append(";");
    buff.append("_dl[\"");
    buff.append(clientId);
    buff.append("\"]=");
    buff.append(loc);
    buff.append(";");
    return buff.toString();
    else
    LOG.severe("NULLCLINET_ID_NO_SCRIPT_RENDERED");
    return null;
    else
    return null;
    else
    return null;
    private String _getLocaleString(FacesContext context)
    Locale dateTimeConverterLocale = getLocale();
    if (dateTimeConverterLocale != null)
    Locale defaultLocale = RenderingContext.getCurrentInstance().getLocaleContext().getFormattingLocale();
    if (!(dateTimeConverterLocale.equals(defaultLocale)))
    String loc = dateTimeConverterLocale.toString();
    StringBuffer sb = new StringBuffer(2 + loc.length());
    sb.append("'");
    sb.append(loc);
    sb.append("'");
    return (sb.toString());
    return "null";
    @Override
    @Deprecated
    public String getClientConversion(FacesContext context, UIComponent component)
    String formatMask = (String) resolveExpression("#{bindings." + component.getId() + ".format}");
    if (formatMask != null)
    String dataType = (String) resolveExpression("#{bindings." + component.getId() + ".attributeDef.javaType.name}");
    if (dataType.equalsIgnoreCase("oracle.jbo.domain.Date") || dataType.equalsIgnoreCase("oracle.jbo.domain.Timestamp"))
    String jsPattern = getJSPattern(context, component);
    Map<String, String> messages = new HashMap<String, String>();
    if (jsPattern != null)
    Class<?> formatclass = formatMask.getClass();
    System.out.println("FormatClass::" + formatclass);
    System.out.println(" Format Mask : " + formatMask);
    // SimpleDateFormat sdfDestination = new SimpleDateFormat(formatMask);
    String pattern = formatMask; //getPattern();
    if (pattern == null)
    pattern = getSecondaryPattern();
    String key = getViolationMessageKey(pattern);
    Object[] params = new Object[]
    { "{0}", "{1}", "{2}" };
    Object msgPattern = getMessagePattern(context, key, params, component);
    //if hintFormat is null, no custom hint for date, time or both has been specified
    String hintFormat = _getHint();
    FacesMessage msg = null;
    String detailMessage = null;
    if (msgPattern != null)
    msg = MessageFactory.getMessage(context, key, msgPattern, params, component);
    detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
    Locale loc = context.getViewRoot().getLocale();
    SimpleDateFormat formatter = new SimpleDateFormat(pattern, loc);
    java.lang.Object obj = resolveExpression("#{bindings." + component.getId() + ".attributeValue}");
    String databaseDate=null;
    if(obj!=null)
    databaseDate = obj.toString();
    DateFormat df = new SimpleDateFormat(pattern,loc);
    System.out.println("DateComponent input value :::::::::::::::::::::::::"+databaseDate);
    Date today;
    try {
    // System.out.println("Before Conversion::::::::::::"+df.parse(databaseDate).toString());
    if(databaseDate!=null)
    today = df.parse(databaseDate);
    else
    today = new Date();
    System.out.println("After Conversion Date :::::::::::::::::::::::::::::"+today.toString());
    //Date today = new Date();
    String dt = formatter.format(today);
    String exampleString = dt;
    String escapedType = XhtmlLafUtils.escapeJS(getType().toUpperCase());
    StringBuilder outBuffer = new StringBuilder();
    outBuffer.append("new TrDateTimeConverter(");
    outBuffer.append(jsPattern);
    // loc = getLocale();
    if (loc != null)
    outBuffer.append(",'");
    outBuffer.append(loc.toString());
    outBuffer.append("','");
    else
    outBuffer.append(",null,'");
    outBuffer.append(exampleString);
    outBuffer.append("','");
    outBuffer.append(escapedType);
    outBuffer.append("'");
    if (msgPattern != null || hintFormat != null)
    messages.put("detail", detailMessage);
    messages.put("hint", hintFormat);
    outBuffer.append(',');
    // try
    // JsonUtils.writeMap(outBuffer, messages, false);
    // catch (IOException e)
    // outBuffer.append("null");
    outBuffer.append(')'); // 2
    return outBuffer.toString();
    catch(ParseException e)
    System.out.println("Parse Exception :::::::::::::::::::::"+e);
    return null;
    else
    // no pattern-matchable date
    return null;
    else
    return null;
    else
    return null;
    protected String getJSPattern(FacesContext context, UIComponent component)
    String jsPattern = null;
    String datePattern = (String) resolveExpression("#{bindings." + component.getId() + ".format}");
    if (datePattern != null)
    String secondaryPattern = getSecondaryPattern();
    if (datePattern != _NO_JS_PATTERN)
    int length = datePattern.length() * 2 + 2;
    if (secondaryPattern != null)
    length = length + 3 + secondaryPattern.length() * 2;
    StringBuilder outBuffer = new StringBuilder(length);
    jsPattern = _getEscapedPattern(outBuffer, datePattern, secondaryPattern);
    else
    jsPattern = datePattern;
    return jsPattern;
    private static void _escapePattern(StringBuilder buffer, String pattern)
    buffer.append('\'');
    XhtmlUtils.escapeJS(buffer, pattern);
    buffer.append('\'');
    private static String _getEscapedPattern(StringBuilder buffer, String pattern, String secondaryPattern)
    if (secondaryPattern != null)
    buffer.append('[');
    _escapePattern(buffer, pattern);
    if (secondaryPattern != null)
    buffer.append(",'");
    XhtmlUtils.escapeJS(buffer, secondaryPattern);
    buffer.append("']");
    return buffer.toString();
    private String _getHint()
    String type = getType();
    if (type.equals("date"))
    return getHintDate();
    else if (type.equals("both"))
    return getHintBoth();
    else
    return getHintTime();
    public static Object resolveExpression(String pExpression)
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp = null;
    valueExp = elFactory.createValueExpression(elContext, pExpression, Object.class);
    return valueExp.getValue(elContext);
    private static final String _NO_JS_PATTERN = new String();
    private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(DateTimeConverter.class);
    // RenderingContext key indicating the _dateFormat object
    // has been created
    private static final String _PATTERN_WRITTEN_KEY = "org.apache.myfaces.trinidadinternal.convert.DateTimeConverter._PATTERN_WRITTEN";
    *Problem is if any input date componet is displaying other than current date then the date picker is always picking the current date rather existing date*
    Please suggest me where to make changes?
    Edited by: 858782 on Oct 3, 2011 7:43 AM
    Edited by: 858782 on Oct 3, 2011 11:44 PM

    I need custom date foramts to be applied for different inputDates which are not defined in <af:convertDateTime>
    Thanks
    Edited by: 858782 on Oct 13, 2011 4:59 PM

Maybe you are looking for