Converting Text to String and vise-versa in Google

2019-06-24 11:39发布

How can one convert from String to Text

java.lang.String

to

com.google.appengine.api.datastore.Text;

and vise-versa?

1条回答
何必那么认真
2楼-- · 2019-06-24 12:37

Check Javadoc about Text class. It has two methods: toString() and getValue(). But toString() returns first 70 characters only.

So, use getValue() instead:

String value = someText.getValue();

Contructor of the Text class supports initialization with a string value. And (as Javadoc says), this object cannot be modified after construction.

查看更多
登录 后发表回答