将字符串的长格式转换为长格式

huangapple go评论62阅读模式
英文:

convert string long format to long format

问题

这里是从服务器获取的日期,并将其存储在字符串 createdDate 中:

createdDate = getIntent().getStringExtra("CreatedDate");

在这里,createdDate 的值为 "1586503375033"

当我将创建的日期发送到服务器时,它将会以 1586503375033 的形式发送:

jsonobject.put("createdDate", createdDate);

我正在像上面这样发送 createdDate

如何去除双引号并将其作为长整型格式发送呢?

英文:

here is my date coming from server and store it is in string createddate:

createdDate = getIntent().getStringExtra("CreatedDate");

here createddate coming as "1586503375033"

when i send the created date to server i will be send as 1586503375033

jsonobject.put("createdDate",createdDate);

i'm sending that createdDate like above

how to remove double quotes and send it as long format

答案1

得分: 3

Long.parseLong(String);
这将完成任务。

英文:

Long.parseLong(String);
This will do the job

答案2

得分: 0

String转换为Long,使用Long.parseLong(createdDate)

英文:

Convert the String to a Long, with Long.parseLong(createdDate).

答案3

得分: 0

Convert String to long using Long.valueOf(String):

String text = "121315465465465465"; // example String
long value = Long.valueOf(text);
英文:

Convert String to long using Long.valueOf(String):

String text = "121315465465465465"; // example String
long value = Long.valueOf(text);

huangapple
  • 本文由 发表于 2020年4月10日 21:06:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/61140910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定