How can I format the "2010-07-14 09:00:02"
date string to depict just "9:00"
?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html
Use
SimpleDateFormat
to convert between a date string and a realDate
object. with aDate
as starting point, you can easily apply formatting based on various patterns as definied in the javadoc of theSimpleDateFormat
(click the blue code link for the Javadoc).Here's a kickoff example:
A very simple way is to use
Formatter
(see date time conversions) or more directlyString.format
as inIf you have date in integers, you could use like here:
I'm assuming your first string is an actual Date object, please correct me if I'm wrong. If so, use the SimpleDateFormat object: http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html. The format string "h:mm" should take care of it.