store values from  <List> String  to <List> Date

Posted on 2007-07-23
Last Modified: 2010-03-30
how to assign values from  <List> String  to <List> Date. The data in the String has a format of "dd/MM/yyyy".
Question by:Yap_YokeWan
    LVL 92

    Accepted Solution

    Use a DateFormatto convert the string,

    Something like:

    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    for (String date : dateStrings)
    LVL 24

    Assisted Solution

    Use SimpleDateFormat with the pattern you specified.
    You must program a loop to transfer the values one by one.


    Author Comment

    i retrieve the list of data (date type) and store into <List> String. I only want the list of dates that is more than the passed in value which is a String type having the date format as "dd/MM/YYYY"
    LVL 20

    Expert Comment


    objects is showing exactly this:
    dateStrings is the list with the List <String>, dates is List <Date>
    And do not forget to initialise dates :)
    What you do not understand?

    PS: NO points for me.
    LVL 26

    Expert Comment

    >>I do not know why you decided to post a program which implements what the experts were telling above and is adding NOTHING new to the real question.

    the earlier posts weren't there when I posted! could be a refresh problem... and I am seeing this kind of posts very usual... See sciuriware's post which describes exactly what Object posted!

    >>Except that it contained all the goodies so that the Asker can just copy-paste without even think...

    Thats an example I had in my harddisk and I don't think that is no more different from pointing a link which has the implementations like that!!!

    >>Additionally you somehow missed even to mention that this is what was already said.

    See my comment earlier!

    LVL 92

    Expert Comment

    > I only want the list of dates that is more than the passed in value which is a String type having the date format as "dd/MM/YYYY"

    then filter inside the loop

       Date d = df.parse(date);
       if (d.after(testDate))
    LVL 26

    Expert Comment

    >>Your comment was almost 2 and a half HOURS after the first two.

    it could be becuase I don't know when I had opened that question, when I returned back I saw the questioned opened and then posted mine!

    >>Are you saying that you did not see the above after you posted as well?

    I could have seen them if I waited for the rendering happen after the post!

    >>Your comment was a fully blown program which adds nothing to the real problem solution compared to the already posted ones. The link shows only how to make the conversion (which is the question)

    I am just participating in forums when I get times. I don't want to argue any more... just leave it!

    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now