String maniplute for exampl Date format

hello every body i need some help with this program.
Req:
INPUT:
date in this form "mm/dd/yyy" range from "1000<=yyyy<=3000"
OUTPUT:
Example:
Enter a date: 05/01/2005
05/01/2005
01/05/2005
2005-05-01
May1, 2005
01 May 2005
5/1/05
That what I did so far, pleas I need your help
import java.lang.*;
import java.util.Scanner;
public class string control
   public static void main (String [] args)
   Scanner scan = new Scanner(System.in);
   String input;
   String day;
   String month;
   String year;
   System.out.print("Enter a date: ");
  input = scan.nextLine();
  int pos= input.indexOf (' ');
  month = input.substring (0,4);
   input = input.substring(pos+1,input.length());
   day= input.substring(0,input.indexOf(' '));
   int locmonthchar = input.indexOf(' ')+1;   // to break it & make it esaier.
  year= input.substring(input.indexOf(' ')+1,input.length());
   String newinput = year + ","+month+day.charAt(0);

Programer2010 wrote:
just write each string as a function
for example: public string getDay()...No. Don't do this if you can avoid it. Use SimpleDateFormat (as suggested above) and with different format strings is in my mind the simplest, most straightforward, and likely correct (if this is homework) answer. check out the API.

Similar Messages

  • I want to take a series of hex characters in a string control and produce an HDLC string indicator for example if the data string control is 3F27 then the HDLC string indicator is 7E003F2700B57E

    I want to take a series of hex characters in a string control and produce an HDLC string indicator for example if the data string control is 3F27 then the HDLC string indicator is 7E003F2700B57E

    "thanks for your help "
    Does that mean you figured it out already?
    If not, see this thread for some HDLC related code.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=146859&query.id=3388#M146859
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is there any system variable for this date format 01/21/2004 18:00:32

    Hello,
    Is there any system variable for this date format 01/21/2004 18:00:32
    This is my Internal date format and my External date format is sy-datum.
    How can I validate....any suggestions will be apprecaited!
    Regards,
    Kittu

    Hello,
    Thank you very much for your response!
    My internal date format is 01/21/2004 18:00:32
    and external date format on selection-screen is sy-datum.
    My external format is stored in S_crtsp
    and internal format is stored in L_crtsp. (01/21/2004 18:00:32)
    I want to remove the time from the internal format and validate it aginst the external format.
    Any suggestions or brief explonation is appreciated...I apprecaite the help soo far...
    Regards,
    Kittu

  • 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>

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Custom error message for invalid date format

    Hi,
    I am using af:selectInputDate component for date. When i enter wrong date format it comes up follwoing pop up error message:
    The value "12/13/2009" is not a valid date. Valid example ""29/11/2005".
    However i dont want to show this standard message but a customised error message like "the value is not in correct format...".
    Can anyone help me how can i show customised message.

    Hi Kiran
    Try these options
    1) Change your <b>Internet Explorer</b> [The Browser which you are using] language
    2) In Application Level, ie in Webdynpro
    a)Go to <b><Your project name>>Webdynpro>Applications--><Your Application>
    Double click on your Application name</b>b) Go to Application Properties TAB, Add a New Application Property
    c) Click on "<b>Browse</b>" and Select <b>DefaultLocale</b> and mention the Value as
    <b>en_US</b> [If you didnt mention any thing here by default it will take browser's language]
    3)In your Portal check the language setting of particular user in identity management
    Warm Regards
    Chaitanya.A

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • Deserializing error for the Data format

    Hi,
    We have created a RFC FM. Which will be call from other non-sap system.
    Where other non-sap system was using dot net.
    While they are calling our custom RFC there are getting a problem with date format. The error says as follows
    - <n0:SimpleTransformationFault xmlns:n0="http://www.sap.com/transformation-templates">
                <MainName>/1BCDWB/WSS0070718161009712605</MainName>
                 <ProgName>/1BCDWB/WSS0070718161009712605</ProgName>
                 <Line>74</Line>
                 <Valid>X</Valid>
    - <DeserialisationFault>
                <DescriptionText>An error occurred when deserializing in the simple transformation program /1BCDWB/WSS0070718161009712605</DescriptionText>
                 <DescriptionDetailText>The date 20060728 is not a valid date according to the XML format for ABAP</DescriptionDetailText>
                <TreePosition />
                <ClassName>CX_SY_CONVERSION_NO_DATE_TIME</ClassName>
                </DeserialisationFault>
    - <Caller>
                <Class>CL_SRG_RFC_PROXY_CONTEXT</Class>
                <Method>IF_SXML_PART~DECODE</Method>
                <Positions>1</Positions>
                </Caller>
      </n0:SimpleTransformationFault>
    Could any one help me out regarding this deserialize error with date from?
    Thanks in Advance
    Regards,
    Gopinath Addepalli.

    I believe you may still have issues with your migration. I would first verify that you can perform some basic functions with PWA:
    1) Create, save and publish a new project from browser.
    2) Edit, save and publish one of the migrated projects.
    3) Before doing the migration, do you have all the approvals completed and projects published.
    4) Clear out your cache and try a different project to open.
    5) Open Server Settings, go to Delete Objects and see if your projects are listed for deletion.
    Cheers!
    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Convert string (in a Julian Date format) to a date in CR XI Release 2

    How do you convert a string field  entered in a database as a Julian date " 10109 , 09008. ,,," to
    print on a report as  date?
    09008 would be 01/08/09
    10109                 04/19/10

    A small correction to Brian's formula:
    NumberVar myYear;
    NumberVar myDays;
    myYear := ToNumber( {table.JULIAN} [1 to 2]);
    myDays := TONUMBER({table.JULIAN} [3 to 5]);
    (Date (myYear, 1, 1) + myDays) - 1;
    The result for '09008' will be 01/08/9, by adding ToText, you can get the result in the desired format of 01/08/09.
    totext((Date (myYear, 1, 1) + myDays) - 1, "MM/dd/yy");
    Here is an alternate solution without having to create variables:
    totext(dateserial(tonumber(X[1 to 2]),1,tonumber(X[3 to 5])),"MM/dd/yy");
    where X is the julian date in string.
    Edited by: Sanjay Kodidine on Apr 20, 2010 8:25 AM

  • How to validate for proper date format

    Hi Experts,
    I am using following Fm to calculate date difference.....
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
          exporting
            i_date_from = wa_draw-zdm_vld_to_dat
            i_date_to   = sy-datum
          importing
            e_days      = v_days.
        if sy-subrc = 0 .
          if v_days > 0.
    But value of field  zdm_vld_to_dat (data type DATS  , YYYYMMDD)   in database tables itself is wrong   ...like  ct/-0/29-o
    I want to avoid passing these wrong data entry, in the FM...as also i give info message for this in spool.
    So can anybody tel me How can I detect or know this fields zdm_vld_to_dat  conatins wrong date other than YYYYMMDD...e.g.
    ct/-0/29-o   means any charecter or hyphen
    Thank you.  

    Hi Nilesh Hiwale,
    1. First thing is there is no need for any function module for difference between two dates
        See this.
    Data:
    days type i
    date1 type wa_draw-zdm_vld_to_dat
    date2 type sy-datum.
    days = date2 - date1.
    Write / days.
                          > (OR)
    2. write this condition in PAI module of your screen.
    At selection-screen.
    if date1 cn '1234567890'. or date2 cn '123456789'.
      write e000(Sabapdocu) with 'Enter YYYYMMDD Formate'.
    endif.
    Reward if it is useful,
    Mahi.

  • How can I remove all or part of the information in headers and footers? For example, date and time of printing.

    I cannot find where I can suppress the printing of the date and time of printing or if I want a header and/or footer at all.

    If using the traditional menus, in the File menu select Page Setup
    If using the orange Firefox button, click on it, then select Print and then Page Setup
    Once you have the page Setup dialog displayed, go to the "Margins & Header/Footer" tab. You need to change all of the options for header and footer to "--blank--"

  • Test String for date format

    Is there a function that reads a string and can return yes/no if the string matches a specified date format (example: mm/dd/yy)? I wish to avoid parsing the string character by character.
    Thanks,
    George

    BTW,
    I used the following example code available from this site. I was able to easily modify it to sovle my problem.
    try {
    SimpleDateFormat formatter =
    new SimpleDateFormat("EEEE, MMMM dd, yyyy");
    Date d = formatter.parse(
    "Tuesday, January 03, 1956");
    formatter = new SimpleDateFormat(
    "EE, MMM d, yy");
    d = formatter.parse("Tue, Jan 3, 56");
    formatter = new SimpleDateFormat(
    "EE, MM d, yy");
    d = formatter.parse("Tue, 01 3, 56");
    process(d);
    } catch (ParseException e) {
    On to the next challenge...
    George

  • Refer to Doc ID 825030 which talks about applying of patch for correction of date format in web adi. Is this patch can be applied on R12.1.3 instance as this patch released date is very old. Please suggest if there is another patch which be applied to cor

    Refer to Doc ID 825030 which talks about applying of patch for correction of date format in web adi. Is this patch can be applied on R12.1.3 instance as this patch released date is very old. Please suggest if there is another patch which be applied to correct the date format in web adi. currently the date is coming in number format.

    Hello,
    This document is for 11i Date Format Changes When Loaded Into Webadi (Doc ID 825030.1)
    use this document instead for R12 : Incorrect Date Format in Excel Sheet Generated Via WebADI (Doc ID 828253.1)
    <Moderator Edit - deleted MOS Doc content - pl do NOT post such content>
    Best Regards,
    Eric.

  • Apple-date-format for Mail Stationary

    my date for my mail stationary is not updating as it used to since i have upgraded to Mavericks
    this was my code before: (works only with Mountain Lion)
    <span class="AppleStationeryDynamicElement" contenteditable="true" apple-content-type="date" apple-date-format="%b %1d, %Y">xxxxx</span>
    this is my code now: (works only with Mavericks)
    <span class="AppleStationeryDynamicElement" contenteditable="true" apple-content-type="date" apple-date-format="EEE, MMM d, ''yy"></span>
    any one have idea what shuld i use for the date format that would work both Mountain Lion and Mavericks?
    Thanks!

    Steve,
    I think that you may have the "wrong" choice in the Systems Preferences/International preference pane. If this is set to "United Kingdom" then Mail will generate iCal events with the correct date.
    However, if (like me) you customise this in any way, OS X creates a "Custom" profile. This is no longer recognised by Mail as using UK date formats and the program then seems to default to choosing US dates. So, if you are willing to lose your customisation and switch back to the standard "United Kingdom" choices this should work.
    It is just a shame that you can't have a UK date format, and some customisation of (for instance) the date/time display.

Maybe you are looking for