Date Fprmat Validation.. (yyyy-MM-dd-hh-mm-ss)

Hi All,
In a application i am trying to validate a dateTime string in this particular format.
yyyy-MM-dd-hh-mm-ss
The code which i am using for this validation is
public boolean validateDate(String date)
DateFormat date_formatter = new SimpleDateFormat(
"yyyy-MM-dd-hh-mm-ss");
date_formatter.setLenient(false);
ParsePosition position = new ParsePosition(0);
if (null == date_formatter.parse(date, position))
return false;
else
return true;
If the input is 2007-12-12-12-12-12|1211 the method is returning true where as the method should return false.
Can any one suggest correction to the above code so that it work correctly for the above and its kind of input?
And also this method returns false for the date time input in 24 Hr format
eg. 2007-12-12-22-10-55 but the expectation is to get true as the return value from the method.

avoid multi post
http://forum.java.sun.com/thread.jspa?threadID=5221672

Similar Messages

  • Why is this date{MM-DD-YYYY} not a valid pattern?

    I'm tyring to define a new date pattern, date{MM-DD-YYYY}, in Adobe Desinger 7 and it kept saying the pattern is not valid. Please help.

    Never mind. I got it.

  • Date Range valid check on BSP Application

    Hallo,
    i want to  display brochures with its validity date in BSP application.Can anybody help me. i was rejected because i posted my code here ,i cant post it again.
    regards

    hi,
    In which block  you want to keep the validation . In Layout of in Onevent processing block. ??
    <script for="sd" event=onchange type="text/javascript">
    var data = this.value;
    var date = data.split(".");
    if (data != ' ')
    var day = date[0];
    var month = date[1];
    var year = date[2];
    if ((day<1 || day >31) || (month<1 || month>12) ||(year.length != 4))
    alert("Please enter a valid  Date ( mm.dd.yyyy )");
    endif.
    hw come ur post  got reject ?
    Please specify whr u want to embed validation .

  • Given String Date is valid/not?

    Hi Friends,
    I am getting date in string format e.g.
              String creationDate = "2007/02/30";
    I want to check is valid or not. see in the example I have given 30 Feb 2007 which is invalid date. Is there any way to check the date is valid or not.
    Any help will be appreciable for me.
    Thanks in advance...
    - Hiren Modi

    use the java.text.SimpleDateFormat. The strategy is to instanstiate a SimpleDateFormat with the date pattern and then parse the input string with it to produce a java.util.Date. This in turn is fed back in the same SimpleDateFormat instance for formatting resulting in a String which is then compared to the input string. If they are not equal then the input string is an invalid date. something like
    String input = "2007/02/30";
            String output = null;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            try {
                Date date = sdf.parse(input);
                output = sdf.format(date);
                if (!input.equals(output)) throw new IllegalArgumentException("invalid date");  // or however you want to handle it
            } catch (ParseException ex) {
                ex.printStackTrace();
            }

  • In IOS 6 my date format was YYYY-MM-DD. When I switched to IOS 7, it changed to MM-DD-YYYY. How do you change it?

    In IOS 6 my date format was YYYY-MM-DD, which is ISO 8601 standard used in Canada.  When I switched to IOS 7, it changed to MM-DD-YYYY format which is very confusing as all my cameras etc use YYYY-MM-DD.  How do you change it, like one can in OSX?

    It appears previous versions of IOS would pick up your preferred date format from your OSX Mac. You can modify that to whatever you like.
    Now if you select Canadian or American in IOS 7 you get only MM-DD-YYYY.  This is wrong for Canada as the preferred date format here is YYYY-MM-DD, just check your birth or expiry dates on your Ontario Drivers License or OHIP Health Card.  Or the date field at the bottom left of any Government of Canada website.
    The trouble with using other Country codes is you tend to get their currency codes like € or £ and the terms like yesterday and today in their language.

  • How to convert Date format from yyyy mm dd   to   dd mmm yyyy in ADF

    Hi,
    I have Date Format in Data Base as yyyy mm dd, but in the UI I want to display the format as dd mmm yyyy, which code I have to write to get the required format in JDev 11.1.2.3

    Hi,
    Use converter : &amp;lt;af:convertDateTime&amp;gt;
    See also : convertDateTime Demo
    -Arun

  • How to create an item with date type mm/yyyy (no day)

    Hello,
    Is it possible to create an item with date type mm/yyyy (no day)? I want the pop-up date picker to just show month and year.
    Thanks,
    Jen

    Hi,
    you cannot pop-up date picker to just show month and year, but you can set your item format as MM-YYYY
    You can check this APEX_ITEM.DATE_POPUP2 at : http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_item.htm#CHDJHBCG (if using apex 4.1) else http://docs.oracle.com/cd/E10513_01/doc/apirefs.310/e12855/apex_item.htm#CHDFDDEI
    Edited by: Sergio_doudou on 2012-04-13 14:26

  • Function module to verify if date is valid.

    Anyone know a function module to verify if date is valid?thx

    hiiii
    This function module will be useful.check.
    FM CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
    EXPORTING
    date = pre_date
    EXCEPTIONS
    plausibility_check_failed = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e002(0s) WITH pre_date.
    ENDIF.
    reward if useful
    thx
    twinkal

  • I want to change the date format MM/YYYY to MM.YYYY in web report

    Hi to all experts,
       Here  the problem is: when i run a report for variable input when we select date as MM/YYYY its getting error . Here i need to change MM/YYYY to MM.YYYY. can u please tell me where exactly i need to change means in BEx or Web? if it is BEx where it is exactly pls tell m ethe step to step procedure.
    Its urgent!
    ( I will assign the points if its useful to me)
    Advance Thanks,
    Shah

    Hi Siggi,
            In su01 if we go  and change the date format from MM/YYYY to MM.YYYY  for a particular user ex:ss11 , if another user ex:bst55 try to run the web report he/she may get same error .If we make the change in su01-> default tab->under date format for a particular user , is it work for other users?
    Can u tell me step by step where exactly we need to go in AWB and where need to modify.
    I am looking for ur answer.
    Thanks in Advance
    Shah

  • What  are the usual date field validations

    Hi all,
    can you please tell me what  are the usual date field validations in selection Screen
    Thanks and regards ,
    Madhavi pilla

    Once you declare it as TYPE SY-DATUM, usually that is enough.  Sometimes we will also check that it is not less than '18000101' or greater than '99991231'.  Or if you have a specific date range that applies to your program you could check the field contents against that. I hope this helps.
    - April King

  • How can i get todays date as an yyyy-MM-dd format instead of Time stamp

    how can i get todays date as an yyyy-MM-dd format instead of Time stamp,i try to do it in the fallowing way
    <code>
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
         java.util.Date d = new java.util.Date();
              String s = d+"";
    Calendar cal1 = Calendar.getInstance();
         try{
         cal1.setTime(sdf.parse(s));
    }catch(Exception e){}
    </code>
    but i could not able to get,it throws error as an java.text.ParseException: Unparseable date: "Thu Jan 24 11:43:32 EST 2002" ,pl suggest me any solution.any help would be appreciated.
    Regards.

    Does string s have to end with ""?
    Try doing sdf.format(d) instead.

  • Convertinf Date format from YYYY-MM-DD to MMDDYYYY

    Hi Experts,
              I want to convert  date format from yyyy-MM-dd  to MMDDYYYY ( i am using this format in the file strucure),
             i tryed using date tranfer funcion source as yyyy-MM-dd and target as yyyyMMdd this is working fine.
    i tryed using date tranfer funcion source as yyyy-MM-dd and target as MMddyyyy this is giving error.
    Please help me out,
    Thanks,
    Dhanush

    Hi,
    From the error it looks like the date value is coming as blank in the source. please give the date in the same format as you have provided in datetrans function and test it again. It will work.
    It might be possible that there are some other date fields in your source where you are not passing any value and using datefunction. please look carefully at all the source structure and data.
    thanks
    amit
    reward point if suggestion works

  • Input is 10 digit date (dd/mm/yyyy) some times instead of date they will se

    Hi Experts,
    requirement is
    input is 10 digit date (dd/mm/yyyy) some times instead of date they will send as space(10 digit). it should not fail in PI.
    kindly help me on this.
    regards
    Elton

    HI,
    I have given like
    if input equals to constant(space)
    then constant(space)----
    > here you have to pass constant date / system date
    else
    input
    input -> constant(10 space) -> equals ->if ->
    then -> constant(date) ->target
    else -> input->target filed
    thanks,

  • Web Gallery with Date (dd-mm-yyyy) and Caption metadata only

    Aperture is a great product.
    I would like to add the date (dd-mm-yyyy) and caption to my photos but do not have that combination in the metadata drop down.
    How do I customize this?
    Thanks, Paul.
    iMac Intel Core Duo 20", 2 GB RAM   Mac OS X (10.4.4)   Nikon Coolscan V ED, Nikon D200, Iomega MiniMax Drives

    I want to put caption and date (but not time) on each photo in a photobook. I've finished laying out the book and only just discovered that I can't do it. The metadata button has many options but not caption and date together.
    Any ideas?
    Thanks
    John
    iMac Intel 20"   Mac OS X (10.4.5)  

  • Checks the complete date (mm/dd/yyyy) against another compelete date (mm/dd/yyyy)

    Hi,
    Is there a cold fusion function that checks the complete date (mm/dd/yyyy) against another compelete date (mm/dd/yyyy)?
    I have used the DateCompare but it only checks the month, day or year depending on the precision being used.
    Thanks,
    Mike

    I think you might need to read the docs a bit more closely.  From the docs for dateCompare():
    datePart
    Optional. String. Precision of the comparison.
    s Precise to the second (default)
    n Precise to the minute
    h Precise to the hour
    d Precise to the day
    m Precise to the month
    yyyy Precise to the year
    Indeed, even by default its behaviour is not what you suggest it is.
    Adam

Maybe you are looking for