is this possible to get the output in Date type in the below format
> 2014-11-12 09:23:47 GMT+05:30
not to be like
> Wed Nov 12 06:53:47 IST 2014
is this possible to get the output in Date type in the below format
> 2014-11-12 09:23:47 GMT+05:30
not to be like
> Wed Nov 12 06:53:47 IST 2014
That can be done using SimpleDateFormat
with the format string:
yyyy-MM-dd HH:mm:ss 'GMT'XXX
as per the following program:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test {
public static void main(String[] args) {
Date dt1 = new Date();
DateFormat df = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss 'GMT'XXX");
String line = df.format(dt1);
System.out.println(line);
}
}
On my system, that gives me:
2014-11-14 15:36:16 GMT+08:00