Hi, everyone I am inquiring because it was blocked while making a chatbot using dialog flow.
SimpleDateFormat weatherDateFormatFromString = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
You created a variable in and converted the time value from the dialog flow to unix time as follows:
date = weatherDateFormatFromString.parse(totalDateTime).getTime();
However, if you reformat() the converted time value as shown above, the time (pm -> am) changes.
System.out.println ("Check (date, time exists). value before parsing.totalDateTime: " + totalDateTime);
date = weatherDateFormatFromString.parse(totalDateTime).getTime();
System.out.println ("Check (date, time exists). Reconversion after parsing: " + weatherDateFormatFromString.format(date)));
If you look at the output value after writing the code as shown above, you can see that the time changes as shown below.
com.updatetest.chatbotproject I/System.out: Confirm (date, time exists). Pre-parsing value: 2019-03-18 16:00:00
com.updatetest.chatbotproject I/System.out: confirmation (date, time exists). Re-conversion after parsing: 2019-03-1804:00:00
I don't know why this difference occurs when I just re-converted the same time. Due to the above problem, if you ask the weather on the chatbot separately in the morning and afternoon, the weather at the wrong time occurs.
If there's anyone who knows, please answer!
android ampm parse dialogflow chatbot
hh is represented only by 1-12 values If you do HH, it'll be expressed as 0-23.
© 2024 OneMinuteCode. All rights reserved.