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: I want to extract minutes and seconds from duration

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I want to extract minutes and seconds from duration

    I have read a text file into BufferedReader

    my first line and second has this information:

    Date Time Number Duration
    01/01/2007 00:01 0202332981 1:04
    How can I derive the minutes and seconds and save it to String minutes, seconds. This is an extract of code I have written so far:

    String strLine;
    	    //Read File Line By Line
    	    while ((strLine = br.readLine()) != null)   {
    	      // What do I do with strLine so the minutes and seconds are extracted?
     
    	    }

    Thank you


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,308
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: I want to extract minutes and seconds from duration

    See the API for String. It has many helpful methods that you can use to parse those strings into what you want (indexOf, split, etc...). You could also use a StringTokenizer (Java Platform SE 6) to loop over the values in each line

Similar Threads

  1. Really Quick n00b question, should take three seconds to answer
    By joeschmidt45 in forum Java Theory & Questions
    Replies: 4
    Last Post: February 24th, 2011, 04:23 AM
  2. How to extract text from web
    By HelloAll in forum Java Theory & Questions
    Replies: 4
    Last Post: January 10th, 2011, 04:50 AM
  3. how to extract variables,keywords,operator...
    By Nanda in forum Java Theory & Questions
    Replies: 1
    Last Post: November 12th, 2009, 09:19 PM
  4. A program that reads in secounds, and prints out hours minutes
    By CYKO in forum Java Theory & Questions
    Replies: 1
    Last Post: September 13th, 2009, 10:42 PM
  5. “Getting started with RMI” tutorial for beginners
    By danielstoner in forum Java Programming Tutorials
    Replies: 0
    Last Post: October 7th, 2008, 11:18 PM