• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two text packages of Java, which to use?

 
Walter Gabrielsen Iii
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to parse text. I'm looking at two packages in Java's API:
java.text
java.util.regex

They both appear to have what I want, so how do I choose which one to use? Which one is recommended, and why does Java have two text packages anyway?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One is focused on regular expressions. Do you really think that date and number formatting should be placed in the regex package?
 
Paul Clapham
Sheriff
Posts: 21113
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why there has to be a choice between packages. Why is there a rule which says you can't use classes from both packages if you need to do that?
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guess you haven't found javax.swing.text yet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic