I have some code which works out the epoch time for the first day of the current month. How would i convert this to a normal date so i can then access which day the first of the month was?
Asked
Active
Viewed 1,650 times
1
-
`Date` has a constructor that takes a long representing the epoch time. – Chris Fei Mar 16 '12 at 03:21
-
Could you provide an example of this constructor being used? – nexus490 Mar 16 '12 at 03:23
-
`Date` is *mostly* deprecated. If possible, update to `Calendar` – Jon Egeland Mar 16 '12 at 03:23
-
try this `String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000));` – ρяσѕρєя K Mar 16 '12 at 03:24
-
it should have given me the first of march. instead it gave 28/02/44134 21:11:11 – nexus490 Mar 16 '12 at 03:28
-
@nexus490 see this one maybe helpful [Converting Epoch time to date](http://stackoverflow.com/questions/7740972/convert-epoch-time-to-date) – ρяσѕρєя K Mar 16 '12 at 03:29
1 Answers
1
Use the SimpleDateFormat object in the Java API.
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Very simple and very clean.

jjNford
- 5,170
- 7
- 40
- 64