-4

How to change timestamp format to other format?

The default is "yyyy-MM-dd hh:mm:ss" and I need 'dd-MON-yyy hh24:mi:ss' (like in Oracle).

I searched on this site and I found some answers, but I could not match them to my needs.

Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103
user2188596
  • 1
  • 1
  • 5

3 Answers3

2

I am not sure if this is, what you are looking for: http://www.java2s.com/Tutorial/Java/0040__Data-Type/SimpleDateFormat.htm

Albi
  • 310
  • 2
  • 13
0

Use Simple Date Format like below

Date date=new SimpleDateFormat("dd-MMM-yyy HH:mm:ss").parse(stringToBeParsed);

Hope this helps.

Darshan Lila
  • 5,772
  • 2
  • 24
  • 34
0

i think you want GMT String format 21 Jul 2014 12:22:34 GMT,

here i used as below, passed time in long...

new Timestamp(System.currentTimeMillis()).toGMTString()

j1g4r
  • 1
  • 2