Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Splitting a String which is Double Hours Method

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Location
    Indianapolis, Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Splitting a String which is Double Hours Method

    Hello I am really struggling to make the Split String method work with another method which is double hours.

    	HtmlElement span = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
    		span.setValue("Drive Time: ");
    		td.addNestedElement(span);
     
    		HtmlElement span2 = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
    		span2.addAttribute("class", "drive_time");
    		String time=String.valueOf(showSet.getTransferHours());
    		/*Split the Strings into Hours and Minutes*/
    		 /*var xDate="::";*/
    		 /*alert(xDate.replace(":"," hrs, ").replace(":"," min and ");*/
    		 /*t = Time(double)*/
         	/*hours(double) = t / 60.0d;*/ 
    		/*minutes(int) = t % 60;*/
    		 /*hour = parseInt(arr[0]) + " hr";*/
    		 /*min = parseInt(arr[1]) + " min";*/
     
    		DateFormat formatter = null;
            Date getTransferHours = null;
     
            //SimpleDateFormat also allows to include time information e.g. HH:mm
            String date = "hh:mm";
            formatter = new SimpleDateFormat("HH:mm");
            getTransferHours = (Date) formatter.parse(date);
            System.out.println("Date from HH:mm String in Java : " 
                                + getTransferHours);
     
     
     
         	span2.setValue((String.indexOf(showSet.getTransferHours()) + " hr "  ));
    	    /*span2.setValue((String.indexOf(showSet.getTransferHours(min))) + " min" ));*/ 
     
    		td.addNestedElement(span2);
     
    		tr.addNestedElement(td);
     
    		return tr;

    Any suggestions appreciated.

    Thanks,
    Michele


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Splitting a String which is Double Hours Method

    What does this code do? What do you want it to do? Where is your MCVE?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Splitting up main method / class
    By Scren in forum What's Wrong With My Code?
    Replies: 53
    Last Post: February 8th, 2014, 04:54 PM
  2. Splitting a String by number of characters
    By torrie in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 24th, 2013, 10:58 PM
  3. Help with splitting string in PDF Generator Function
    By efluvio in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 21st, 2012, 05:43 PM
  4. Splitting String
    By JuLiAnc in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 17th, 2011, 10:23 AM
  5. [SOLVED] Splitting String by Multiple Delimiters
    By relixus in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 4th, 2011, 08:54 PM

Tags for this Thread