Solved

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?

  • 5 February 2019
  • 2 replies
  • 1 view

String text = "John.Davidson/05051988/Belgrade Michael.Barton/01011968/Krakov Ivan.Perkinson/23051986/Moscow";

icon

Best answer by chrisatsafe 5 February 2019, 20:27

View original

2 replies

Badge +2

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.

0684Q00000ArJhUQAV.png

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:0684Q00000ArJqWQAV.png

Output

0684Q00000ArJzTQAV.png

 

Helpful Resources:

Badge +8

Use AttributeSplitter with / in delimeter and after

Use DateTimeConverter with _list{1}, _list{4}, _list{6} and Outpurt Format with %d.%m.%Y

Reply