making empty string to Integer null

79 views
Skip to first unread message

Doug Horn

unread,
Oct 4, 2011, 1:13:11 PM10/4/11
to Fixedformat4j User List
I am parsing a file where there are Integer fields that are sometimes
empty strings (blank). These are be converted to zeros.

Is there any easy way for empty string to be a null on the Integer
object? I need to know if these fields are blanks or really zeros.

@Field(offset = 4, length = 2, align = Align.RIGHT)
public Integer getAmount() {
return amount;
}

Doug Horn

Ann Campbell

unread,
Oct 5, 2011, 5:59:54 PM10/5/11
to fixedformat...@googlegroups.com
I don't remember off-hand if the converter was for Integer or int (&
your instance is being promoted.) But either way it looks like you'll
need to do custom formatter.

Or you could take the lazy way out: do fixed-format parsing for a
string & then do your own 0/null conversion.

> --
> You received this message because you are subscribed to the Google Groups "Fixedformat4j User List" group.
> To post to this group, send email to fixedformat...@googlegroups.com.
> To unsubscribe from this group, send email to fixedformat4j-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/fixedformat4j-user-list?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages