String text = "John.Davidson/05051988/Belgrade Michael.Barton/01011968/Krakov Ivan.Perkinson/23051986/Moscow";
Hello everyone!I am new in Java programing.How can i pull out attributes for each object Person from this String?Also date must be formatted in for example "05.05.1988".How?
Best answer by chrisatsafe
Hi @nenicstefan,
This task can be broken down into 3 sections.
Step 1 - Separate Features
In order to separate the attributes, you will first have to separate your features. You can accomplish this using an AttributeSplitter and setting the delimiter to " " (single space). Next, your features will be stored in a list which should be exploded by a ListExploder.
Using the sample text string you provided, the output of the ListExploder will be 3 features that are formatted as follows:
John.Davidson/05051988/Belgrade
Step 2 - Separate Attributes
Use a second AttributeSplitter to separate attributes by the "/" delimiter. Next, use an AttributeManager to create attribute names, assign attribute values from the list created by the second AttributeSplitter, and remove unwanted attributes.
Note: if you want to replace the space between first and last name, you can use a StringReplacer to replace the "." with " " (space).
Step 3 - Format the Date
The final step is to use a DateTimeConverter to format the date in your preferred format. In this case, you should specify the input format
%d%m%Y
and Output Format:
%d.%m.%Y
This should leave you with a workspace that looks something like this:
Output
Helpful Resources:
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.