Thread: Please help!!!

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    1
    Rep Power
    0

    Please help!!!


    The program is supposed to convert a given date from DD/MM/YYYY to MM/DD/YYYY. Right now, the only thing it will do is that it will take the given date and print out to the screen multiple times. Is there any way anyone can help me?
    /import jpb.*;

    public class convertdate{
    public static void main (String[] args) {
    // Declaration of variables used for assignment statements
    String smonth, sday, syear;
    int imonth, iday, iyear;

    // Prompts the user to enter data
    //SimpleIO.prompt ("Enter a date (month/day/year):");

    //String date1 = SimpleIO.readLine();
    String date1="15/May/2003";

    // Removes invisible characters from the date
    String date2 = date1.trim();
    int lengthdate2 = date2.length(); // Length of date

    // Extracts the month
    int indexMonth = date2.indexOf("/",0);
    String month = date2.substring(0, indexMonth);
    String month2 = date2.trim();

    // Extracts the day
    int indexDay = date2.indexOf("/", indexMonth);
    String day = date2.substring(indexMonth, indexDay);
    String day2 = date2.trim();

    // Extracts the year
    int indexYear = date2.lastIndexOf("/", lengthdate2);
    String year = date2.substring(indexYear, lengthdate2);
    String year2 = date2.trim();

    // Displays the converted date
    System.out.println(" Converted date:" + month2 + day2 + year2);



    }

    } // end class
    Last edited by tosin; February 20th, 2003 at 03:02 PM.
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Your file is empty.

IMN logo majestic logo threadwatch logo seochat tools logo