Skip to main content
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?


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

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.

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:

View original
Did this help you find an answer to your question?

2 replies

chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • Best Answer
  • February 5, 2019

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:


philippeb
Enthusiast
Forum|alt.badge.img+20
  • Enthusiast
  • February 5, 2019

Use AttributeSplitter with / in delimeter and after

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings