Unparseable Date in android, pattern character 'T'Illegal pattern character 'T' when parsing a date string to java.util.DateHow to convert a string date “2019-04-21T12:08:35” to SimpleDateFormat, there by convert to Date?Is there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Get current time and date on AndroidProper use cases for Android UserManager.isUserAGoat()?EditText: how to delete characters obtained from a Json
How to make payment on the internet without leaving a money trail?
Unbreakable Formation vs. Cry of the Carnarium
Where to refill my bottle in India?
Add an angle to a sphere
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Is Social Media Science Fiction?
Why is the design of haulage companies so “special”?
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
What is the meaning of "of trouble" in the following sentence?
aging parents with no investments
Is Fable (1996) connected in any way to the Fable franchise from Lionhead Studios?
How to create a consistent feel for character names in a fantasy setting?
How many letters suffice to construct words with no repetition?
Lied on resume at previous job
Re-submission of rejected manuscript without informing co-authors
Is every set a filtered colimit of finite sets?
Can I find out the caloric content of bread by dehydrating it?
What happens when a metallic dragon and a chromatic dragon mate?
Pristine Bit Checking
Are objects structures and/or vice versa?
"My colleague's body is amazing"
Symmetry in quantum mechanics
When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?
Unparseable Date in android, pattern character 'T'
Illegal pattern character 'T' when parsing a date string to java.util.DateHow to convert a string date “2019-04-21T12:08:35” to SimpleDateFormat, there by convert to Date?Is there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Get current time and date on AndroidProper use cases for Android UserManager.isUserAGoat()?EditText: how to delete characters obtained from a Json
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Is there any way I can remove characters from an EditText brought from a JSONObject response? Example: 2019-03-06T00:00:00 and only present the chain in this way: 2019-02-10, when making the conversion I throw an exception which is:
java.lang.IllegalArgumentException: Illegal pattern character 'T'
Code:
String yourJsonDateString = jsonResponse.getString(DataManager.Birthdate);
try
Date yourJsonDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS").parse(yourJsonDateString);
String newDateString = new SimpleDateFormat("yyyy-MM-dd").format(yourJsonDate);
System.out.println(newDateString);
catch (ParseException e)
e.printStackTrace();
java
|
show 1 more comment
Is there any way I can remove characters from an EditText brought from a JSONObject response? Example: 2019-03-06T00:00:00 and only present the chain in this way: 2019-02-10, when making the conversion I throw an exception which is:
java.lang.IllegalArgumentException: Illegal pattern character 'T'
Code:
String yourJsonDateString = jsonResponse.getString(DataManager.Birthdate);
try
Date yourJsonDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS").parse(yourJsonDateString);
String newDateString = new SimpleDateFormat("yyyy-MM-dd").format(yourJsonDate);
System.out.println(newDateString);
catch (ParseException e)
e.printStackTrace();
java
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
1
Check this answer out
– StaticBeagle
Mar 22 at 1:53
From the json get this string."2019-03-06T00:00:00"
– Gregorio Tancitaro
Mar 22 at 14:44
As an aside consider throwing away the long outmoded and notoriously troublesomeSimpleDateFormatand friends, and adding ThreeTenABP to your Android project in order to usejava.time, the modern Java date and time API. It is so much nicer to work with.
– Ole V.V.
Mar 23 at 9:48
1
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52
|
show 1 more comment
Is there any way I can remove characters from an EditText brought from a JSONObject response? Example: 2019-03-06T00:00:00 and only present the chain in this way: 2019-02-10, when making the conversion I throw an exception which is:
java.lang.IllegalArgumentException: Illegal pattern character 'T'
Code:
String yourJsonDateString = jsonResponse.getString(DataManager.Birthdate);
try
Date yourJsonDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS").parse(yourJsonDateString);
String newDateString = new SimpleDateFormat("yyyy-MM-dd").format(yourJsonDate);
System.out.println(newDateString);
catch (ParseException e)
e.printStackTrace();
java
Is there any way I can remove characters from an EditText brought from a JSONObject response? Example: 2019-03-06T00:00:00 and only present the chain in this way: 2019-02-10, when making the conversion I throw an exception which is:
java.lang.IllegalArgumentException: Illegal pattern character 'T'
Code:
String yourJsonDateString = jsonResponse.getString(DataManager.Birthdate);
try
Date yourJsonDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS").parse(yourJsonDateString);
String newDateString = new SimpleDateFormat("yyyy-MM-dd").format(yourJsonDate);
System.out.println(newDateString);
catch (ParseException e)
e.printStackTrace();
java
java
edited Mar 23 at 9:49
Ole V.V.
32.5k74258
32.5k74258
asked Mar 22 at 1:41
Gregorio TancitaroGregorio Tancitaro
254
254
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
1
Check this answer out
– StaticBeagle
Mar 22 at 1:53
From the json get this string."2019-03-06T00:00:00"
– Gregorio Tancitaro
Mar 22 at 14:44
As an aside consider throwing away the long outmoded and notoriously troublesomeSimpleDateFormatand friends, and adding ThreeTenABP to your Android project in order to usejava.time, the modern Java date and time API. It is so much nicer to work with.
– Ole V.V.
Mar 23 at 9:48
1
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52
|
show 1 more comment
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
1
Check this answer out
– StaticBeagle
Mar 22 at 1:53
From the json get this string."2019-03-06T00:00:00"
– Gregorio Tancitaro
Mar 22 at 14:44
As an aside consider throwing away the long outmoded and notoriously troublesomeSimpleDateFormatand friends, and adding ThreeTenABP to your Android project in order to usejava.time, the modern Java date and time API. It is so much nicer to work with.
– Ole V.V.
Mar 23 at 9:48
1
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
1
1
Check this answer out
– StaticBeagle
Mar 22 at 1:53
Check this answer out
– StaticBeagle
Mar 22 at 1:53
From the json get this string.
"2019-03-06T00:00:00"– Gregorio Tancitaro
Mar 22 at 14:44
From the json get this string.
"2019-03-06T00:00:00"– Gregorio Tancitaro
Mar 22 at 14:44
As an aside consider throwing away the long outmoded and notoriously troublesome
SimpleDateFormat and friends, and adding ThreeTenABP to your Android project in order to use java.time, the modern Java date and time API. It is so much nicer to work with.– Ole V.V.
Mar 23 at 9:48
As an aside consider throwing away the long outmoded and notoriously troublesome
SimpleDateFormat and friends, and adding ThreeTenABP to your Android project in order to use java.time, the modern Java date and time API. It is so much nicer to work with.– Ole V.V.
Mar 23 at 9:48
1
1
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52
|
show 1 more comment
1 Answer
1
active
oldest
votes
To simply 2019-03-06T00:00:00 into 2019-03-06 you can try this.
String dt = dateString.substring(0, 10)
if you use <1000 year dates, or even BCE format. you can use this
String dt = dateString.substring(0, dateString.indexOf("T"))
1
Careful, this will fail for <1000 year dates. Should do something likedateString.substring(0, dateString.indexOf("T"))
– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291688%2funparseable-date-in-android-pattern-character-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To simply 2019-03-06T00:00:00 into 2019-03-06 you can try this.
String dt = dateString.substring(0, 10)
if you use <1000 year dates, or even BCE format. you can use this
String dt = dateString.substring(0, dateString.indexOf("T"))
1
Careful, this will fail for <1000 year dates. Should do something likedateString.substring(0, dateString.indexOf("T"))
– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
add a comment |
To simply 2019-03-06T00:00:00 into 2019-03-06 you can try this.
String dt = dateString.substring(0, 10)
if you use <1000 year dates, or even BCE format. you can use this
String dt = dateString.substring(0, dateString.indexOf("T"))
1
Careful, this will fail for <1000 year dates. Should do something likedateString.substring(0, dateString.indexOf("T"))
– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
add a comment |
To simply 2019-03-06T00:00:00 into 2019-03-06 you can try this.
String dt = dateString.substring(0, 10)
if you use <1000 year dates, or even BCE format. you can use this
String dt = dateString.substring(0, dateString.indexOf("T"))
To simply 2019-03-06T00:00:00 into 2019-03-06 you can try this.
String dt = dateString.substring(0, 10)
if you use <1000 year dates, or even BCE format. you can use this
String dt = dateString.substring(0, dateString.indexOf("T"))
edited Mar 22 at 2:46
answered Mar 22 at 2:28
Andre Bahtiar FauziAndre Bahtiar Fauzi
545
545
1
Careful, this will fail for <1000 year dates. Should do something likedateString.substring(0, dateString.indexOf("T"))
– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
add a comment |
1
Careful, this will fail for <1000 year dates. Should do something likedateString.substring(0, dateString.indexOf("T"))
– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
1
1
Careful, this will fail for <1000 year dates. Should do something like
dateString.substring(0, dateString.indexOf("T"))– Morgan
Mar 22 at 2:34
Careful, this will fail for <1000 year dates. Should do something like
dateString.substring(0, dateString.indexOf("T"))– Morgan
Mar 22 at 2:34
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
thank you for the correction
– Andre Bahtiar Fauzi
Mar 22 at 2:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291688%2funparseable-date-in-android-pattern-character-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What are you using to parse the Json string? What you are receiving is a Date from the Json perspective not a String.
– Juan
Mar 22 at 1:52
1
Check this answer out
– StaticBeagle
Mar 22 at 1:53
From the json get this string.
"2019-03-06T00:00:00"– Gregorio Tancitaro
Mar 22 at 14:44
As an aside consider throwing away the long outmoded and notoriously troublesome
SimpleDateFormatand friends, and adding ThreeTenABP to your Android project in order to usejava.time, the modern Java date and time API. It is so much nicer to work with.– Ole V.V.
Mar 23 at 9:48
1
Nice link, @StaticBeagle, thanks. This one may match even a bit better.
– Ole V.V.
Mar 23 at 9:52