Android-从EditText inputType ="time"获取时间. [英] Android - Get time from EditText inputType="time"
本文介绍了Android-从EditText inputType ="time"获取时间.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的XML文件中有 EditText
:
<EditText
android:id="@+id/etExitHour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:ems="10"
android:inputType="time"
android:hint="exit hour"/>
如何获取用户输入的时间?
How can I get the time that the user enters?
推荐答案
String str = editText.getText().toString();
DateFormat formatter = new SimpleDateFormat("hh:mm:ss a");
Date date = formatter.parse(str);
这篇关于Android-从EditText inputType ="time"获取时间.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文