Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format string date [duplicate]

Tags:

java

string

Possible Duplicate:
String to Date in Different Format in Java

I want to convert String to Date in different Format.

String d = "07:33:01 PM 26/11/2011";

How can i covert it to 26/11-19h30?

like image 298
user1024858 Avatar asked May 17 '26 04:05

user1024858


2 Answers

DateFormat formatter = new SimpleDateFormat("MM/dd-H\hm");
date = (Date)formatter.parse(d);

You will need to import java.util.* and import java.text.*

like image 129
dotancohen Avatar answered May 18 '26 18:05

dotancohen


String d = "07:33:01 PM 26/11/2011";
Date date = new SimpleDateFormat("d/MM-HH\hmm", Locale.ENGLISH).parse(d);
like image 34
Zakaria Avatar answered May 18 '26 16:05

Zakaria



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!