Is is possible to allow multiple date format strings pass DateFormat.parse?

I'm trying to use DateFormat.parse to validate a date in the 20/12/08 format. I would like to allow users to input 20-12-08 or 20 12 08.
The code currently looks like this:
formatter = DateFormat.getDateInstance(DateFormat.SMALL, US);It is currently throwing an exception if 10-12-08 is sent in where as 10/12/08 works just fine.
Is there a alternate us locale that is more lenient?
setLenient(true) didn't solve the problem for me. I think that would accept 32/12/08 not 10-12-08.
I could parse the date string and replace - or ' ' with a /.. Is that best practice?
What other options do I have? Could I use SimpleDateFormat somehow?
Thanks for the input

That just doesn't seem clean. It will work, but I would rather not have a valid application flow use an exception to get its job done.
The application is also international, so many locales on one format is valid. The US user base seems to think they can type in the date however they want. So passed into the method is the locale, I would have to modify a lot of code to send in a list of valid locales.
The best solution for me would be to have a locale that would allow - or ' ' or /. That way I still only have to make one call to df.parse and an exception produces an invalid date message. Is that possible?
Thanks

Similar Messages

  • ADF 10g Allow Multiple Date Formats During Data Entry

    We would like the ability to allow users to enter a date in several different formats. When they tab from the date field (or click out), we would like a custom java method (which we can write) to execute which analyzes what they typed and formats the date as MM/dd/yyyy. Can we do this and how do we get it to execute BEFORE any other validators and/or converters? A simple example is this: the user enters a forward slash (/) into a date field, they tab out, and we populate the date field with the current date.
    Any help and/or ideas is greatly appreciated.
    Thanks,
    Tracy

    Hi,
    actually you will write your own converter and use this instead of the default converter. This is the way you do it. It also ensures that the timing between validation a conversion is fine
    Frank

  • Is it possible to maintain multiple payment formats with a single Program

    Hi,
    Is it possible to maintain multiple payment formats with in a single program.
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer S

    nazzu wrote:
    Hi,
    Is it possible to maintain multiple payment formats with in a single program.
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer SSounds like an Apps question. Start here: https://forums.oracle.com/forums/category.jspa?categoryID=3

  • Multiple date formats using sql developer

    Hello!
    i have 2 date fields in a table.. one is populated using trunc(<date1>) and the other is to_date(<date2>,'YYYYMMDD HH24MISS'). We want <date1> to display as MM/DD/YYYY and <date2> to display as MM/DD/YYYY HH:MI:SS AMPM. When we set the date format under Preference -> Database -> NLS parameter in SQL Developer with a time format it adds 12:00:00 to <date1>, if we take it out, it drops the time in <date2>. What can we do?
    thanks!

    I think what the original poster wanted was to display the two date columns using different formats in the table "Data" tab and AFAIK that is not possible. Setting a date format in the Preferences accomplishes the same thing as the statement
    ALTER SESSION SET NLS_DATE_FORMAT='<some format>';
    in command-line SQL*Plus. To do what the OP wants they'll need to create a view that has a SELECT something like this:
    SELECT TO_CHAR( date1, 'YYYY-MM-DD' ) date1
    , TO_CHAR( date2, 'YYYY-MM-DD HH24:MI:SS') date2
    FROM some_table;
    One thing the OP needs to keep in mind is that the DATE datatype stores both date and time together. If they insert a date alone, the time defaults to midnight. (This is stated in the Oracle SQL Reference.)
    Ed. H.

  • How to get the system date format string?

    Hello, everybody!
    I want to create a MaskFormatter with a mask for dates. So, I could suply as the constructor parameter: "##/##/####'. However, what if the year comes first in the current system date format settings, or the month is in the second place or in the first?... So, I can't just suppose that the current locale format for dates is like the one above. So, my question is: is there a way to get the SYSTEM DATE FORMAT STRING in Java? Searching in google I saw that this was already asked in this forum:
    http://forum.java.sun.com/thread.jspa?threadID=301034&messageID=1193794
    but there was no effective answer. Does someone already know how to get this?
    Thank you.
    Marcos

    Hi, not sure, but
    import java.text.*;
    SimpleDateFormat sdf = new SimpleDateFormat();
    System.out.println(sdf.toPattern());
    will output something like dd/MM/yy HH:mm
    hthThank you very much. It worked.

  • Bad date format string in Crystal 2013

    I have a report that I wrote a formula to convert the date from a number to a date recognizable by the end user. It works fine. The user then wanted to add another field to the same report. Same type of deal, so I copied the first formula into a new formula for the second conversion and simply changed the file name that it was pulling from. When I check the formula, it comes back no errors found, but when I insert it into the report, I get an error that says "Bad date format string" it's the exact same formula that runs fine in the field next to it. What am I  missing? The exact formula as used is;
    date(mid(totext({File.name},0,' '),5,2)+'/'+ right(totext({File.Name},0,' ' ),2) + '/' + left(totext({File.Name},0,' '),4)) It is intended to take it from 20140405 to 04/05/2014.
    Any help would be greatly appreciated. As I am new to Crystal reports and by no means a database administrator by trade.
    Thanks
    Bob V.

    hi Bob,
    you can use something like the following
    stringvar s:= '20140405';
    date(s[1 to 4] + '/' + s[5 to 6] + '/' + s[7 to 8])
    and if you want to be safe and use a check, then you can use something this
    stringvar s:= '20140405';
    s:= s[1 to 4] + '/' + s[5 to 6] + '/' + s[7 to 8];
    if isdate(s) then date(s);
    -jamie

  • How to handle Multiple date formats for the same date field in SQL*Loader

    Dear All,
    I got a requirement where I need to get data from a text file and insert the same into oracle table.
    I am using SQL*Loader to populate the data from the text file into my table.
    The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
    While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
    Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
    Appreciate your response on this.
    Thanks,
    Madhu K.

    The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
    e.g. if you had a value of '07/08/03' how do you know what format that is?
    It could be...
    7th August 2003 (thus assuming it's DD/MM/RR format)
    or
    8th July 2003 (thus assuming it's MM/DD/RR format)
    or
    3rd August 2007 (thus assuming it's RR/MM/DD format)
    or
    8th March 2007 (thus assuming it's RR/DD/MM format)
    or even more obscurely...
    3rd July 2008 (MM/RR/DD)
    or
    7th March 2008 (DD/RR/MM)
    Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
    This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes.

  • Transforming Multiple Date Formats to Consistent Date Format

    I have a power query with some sources use the date format "2014-01-31" and the others use "42029". When I Transform the column to a Date data type, the "2014-01-31" format gets transformed but the "42029"
    stays the same.
    How do I fix this so all dates are in the same format?

    I think one o the issues here is that the format is ambiguous and while the date transform function tries to be very lenient in terms of what it will accept, it can only go so far. If you convert the date to a number first, then Date.From is actually going
    to give you what you want.
    Are there any other columns in your table that can indicate in which format the date it? Otherwise, you could do something like this:
    = Table.AddColumn(Source, "Custom", each if Text.Contains([DateColumn], "-") then Date.From([DateColumn]) else Date.From(Number.From([DateColumn])))
    Here I check if the date string has a "-". If it does, I use Date.From and if it does it I use Date.From with Number.From.
    Tristan

  • I18n for custom date format strings

    I want to internationalize dates shorter than DateFormat.SHORT, in the form "M/d". For example, when the Locale is US, January 16 should display as 1/16, but if the Locale is MX (Mexico), it should display as 16/1.
    It seems like a very simple problem date formatting problem, but it doesn't look like the DateFormat/SimpleDateFormat classes have any way of doing this. Am I missing something?
    --Steven                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You need to apply your own customized date pattern to get the formats you want. I suggest you put the patterns in resource bundles...the default pattern in your default bundle, and the Mexican pattern in your bundle for Mexico. Then do something like this:
    <pre>
    <code>
    String newPattern = "M/d"; // retrieve from bundle instead
    Date today = new Date();
    DateFormat df = DateFormat.getInstance();
    SimpleDateFormat simpleFormat = (SimpleDateFormat)df;
    simpleFormat.applyPattern(newPattern);
    System.out.println(df.format(today);
    </code>
    </pre>

  • Possible to have multiple data sources within 1 SQL querey?

    Hi All,
    Is it possible to join to a table in a different datasource within 1 SQL Querey?
    Something like...
    Connection 1
    Select *
    From Table
    Join
    Connection 2
    On
    Connection1.Table1.Field1 = Connection2.Table2.Field2  Thanks,
    John

    Johnbr (Oracle11G) wrote:
    Is it possible to join to a table in a different datasource within 1 SQL Querey?Called distributed joins - joining a table from one database with that of another database. Also possible to do heterogeneously across different database products - e.g. joining an Oracle table with a SQL-Server table.
    As already explained, some kind of communication interface is needed from the local database to the remote database, in order for the remote table to be read and joined to the local database. This interface is called a database link in Oracle.
    The basic steps. First define the database link:
    create database link <linkname>
      connect to <account>
      identified by <password>
      using <connection-string>Complete syntax details and examples are in the SQL Reference Guide (see http://tahiti.oracle.com)
    After the database link has been identified, you should now be able to address remote tables as follows:
    select * from <remote-table>@<link-name>A distributed join would look something like the following:
    select
    from <local-table> t1,
          <remote-table>@<link-name> t2
    where t1.. = t2..However... this is almost always a BAD IDEA to do distributed joins. It seldom performs well. Performance is immediately constrained to the speed, bandwidth and latency of the network link between local and remote databases. It cannot scale with data volumes and increased frequency of use.
    So if the remote table is not small, the network link not robust and reliable, and join not infrequent, it is bad idea to make use of distributed joins. In which case other alternative (and far superior) features need to be considered instead - like materialised views.

  • Is it possible to select multiple dates from a calendar?

    Hi All,
    I am looking for a way of somehow selecting more than one date in the Apex calendar. What I am after is something like in Outlook you can select 5 days for one action.
    Is something like that (or simmilar) is possible with Apex?
    Regards,
    Pawel.

    Boy, this is something we're struggling with too. So we'd like to hear others' ideas on this also.
    thank you,
    iggy

  • Date Format in Windows

    Is it possible to get the date format from windows locale setting?
    I'm using Java 1.6 and the date format instance for SHORT is not the same as windows locale setting.

    Ah, I see now, sorry.
    Must admit that I do not know the answer to this question. I always thought that Java assumed a 'standardised default' for each Locale and did not actually take any account of the platforms settings. Also, I do not think that the language exposes this information anywhere; I have not conducted an exhaustive search but cannot find anything in the System and Toolkit classes that would seem to give you access to this setting.
    It may be worthwhile searching to see where this setting is exposed throuhg the win32API. That way, you could always write native code to read the setting, access that using JNI and then make use of the setting. That would still leave one problem IMO; what would you do if the user changed the Windows date setting? Alternatively, you could use a ResourecBudnel to parameterise the date string. That would be far easier to implement and allow the user to establish their own (horror) defaults - assuming this is acceptable given the requirements of the application.

  • How to get multiple output formats for each execution of the report?

    Hi,
    Is it possible to get multiple output formats for each execution of the report? If so can you provide some details?
    Thanks

    In Reports 6i, Reports Distribution was introduced. This allows you to run the report once and output to a number of destinations with a different format. It also allows you to distribute individual sections within a report to different destinations in different formats.
    The Destinations for a Report to distribute to are defined either in a distribution file and passed on the command line or inside of the report definition.
    To add a destination to the the report definition, bring up the property palette against the report object and then select the "Distribution" property under the "Report" node. This will bring up a dialog that allows you to create a distribution list. You can then test this list by selecting "file->distribute" from the menu.
    To run a report that is to be distributed through rwrun60, you need to add "distribute=yes" to the command line. It will pick up the destinations from the report definition. If you add "destination=<filename>" then it will pick up the destinations from the specified "<filename>" and ignore the destinations in the report definition.
    Note: if "distribute=yes" is specified on the command line then the destype/desname/desformat parameters will be used to format the report (ie: which printer/display to use during formatting for sizing objects) but will be ignored when the report is sent to the destinations.

  • How can I allow multiple users to edit a single shared iCal calendar?

    Is it possible to allow multiple users to edit a single shared iCal calendar? I also want to provide different permissions to those users. Is this possible through .MAC? Is it possible on Mac OSX Server?

    I would like 2 agenda synced through .Mac but it does not work.
    I have 2 computers and 2 laptops. A very simple agenda with 3 calenders. Myself my partner and the office calender. I want to publish my calender and that of my partner. The office calender I would like to sync so that we can change the office calender at any location.
    I set up sync only for iCall and have a .Mac account. When I change anything on any of the calenders in iCall nothing happens on any of my other locations. Even though the locations are registered as synced. I can see the sync wheel turning but at the end of it the calenders are not synced.
    At this moment I fully understand the publish and unpublished calenders but have no clue what so ever what syncing does for iCall. There seems to be no functionality to it. It does not transport any calender info over .Mac. There is no visable check to see what is happening and the process of syncing is not transperent. Lots of my friends go to me for advise on Apple issues but as far as sync wether iCall or Addressbook I always tell them sync does not work and I have no clue why others have it working. I haven't met any people here in Holland either that got in working. I suppose with iCall you have to get third party software to share calenders editable calenders. Really hopeless situation, wish Apple would just have a manual stating what sync can do and what it can not. Hours wasted on this issue trying to get it to work.
    Hope anyone here can help out.

  • Is it possible to maintain multiple pymt  frmts with in a single prgm 11i

    Hi,
    Is it possible to maintain multiple payment formats with in a single program in 11i
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer S

    nazzu wrote:
    Hi,
    Is it possible to maintain multiple payment formats with in a single program.
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer SSounds like an Apps question. Start here: https://forums.oracle.com/forums/category.jspa?categoryID=3

Maybe you are looking for

  • How to open file system file from Apex?

    Hi, Can someone help me to find how to open a pdf file e.g. test.pdf from apex when someone click on a button ABC? The file is located in /C/ Thanks in advance Dip

  • OCI 22303 exception - Pass object to type Record in oracle procedure

    Recently i had my first encounter with ODP.NET and Oracle. I'm developing a a datalayer that can access a stored procedure on an Oracle database. The problem i'm having is the following: I'm using this method to pass my parameters to the procedure: h

  • Reg Simple Web Dynpro Application

    Hello Gurus, I am developing a simple Web Dynpro Application that displays just Purchase Header Details. It says the runtime Error, "The exception CX_WD_CONTEXT" was raised but was not caught at any stage in Call Hierarchy. Any Suggestions would be r

  • About Query of Routings

    Hi, I've met a serious problem,could anyone help me out?Here's the situation: I used MAPL (PLNTY,PLNNR,PLNAL,ZAEHL)>PLKO (PLNTY,PLNNR,PLNAL,ZAEHL)>PLAS (PLNTY,PLNNR,PLNKN,ZAEHL)>PLPO (ARBID)>CRHD to set up a query,searching routings by Mats. Now I ca

  • Flash Player crashes internet browsers in windows XP

    Hi everybody, from day one when I installed windows and have tried to watch flash content from any video websites like youtube etc..my internet browsers have crashed stating. I have tried IE6, IE7, firfox, safari each of them with flash different ver