Java SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z'”) gives timezone as IST

I have SimpleDateFormat constructor as SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z'”) and I am parsing string “2013-09-29T18:46:19Z”. I have read that here Z represents the GMT/UTC timezone. but when I print this date on console , It prints IST timezne for the returned date. Now my question is whether my output is right or wrong? 8 Answers 8

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an HH-MM-SS string using JavaScript? 32 Answers 32 You can manage to do this without any external JavaScript library with the help of JavaScript Date method like following: var date = new Date(null); date.setSeconds(SECONDS); // specify value for SECONDS here var result = date.toISOString().substr(11, 8); Or, as per @Frank’s … Read more

JavaScript seconds to time string with format hh:mm:ss

I want to convert a duration of time, i.e., number of seconds to colon-separated time string (hh:mm:ss) I found some useful answers here but they all talk about converting to x hours and x minutes format. So is there a tiny snippet that does this in jQuery or just raw JavaScript? 46 Answers 46 String.prototype.toHHMMSS … Read more

Change date format in a Java string

I’ve a String representing a date. String date_s = “2011-01-18 00:00:00.0″; I’d like to convert it to a Date and output it in YYYY-MM-DD format. 2011-01-18 How can I achieve this? Okay, based on the answers I retrieved below, here’s something I’ve tried: String date_s = ” 2011-01-18 00:00:00.0″; SimpleDateFormat dt = new SimpleDateFormat(“yyyyy-mm-dd hh:mm:ss”); … Read more

Javascript add leading zeroes to date

I’ve created this script to calculate the date for 10 days in advance in the format of dd/mm/yyyy: var MyDate = new Date(); var MyDateString = new Date(); MyDate.setDate(MyDate.getDate()+10); MyDateString = MyDate.getDate() + “https://stackoverflow.com/” + (MyDate.getMonth()+1) + “https://stackoverflow.com/” + MyDate.getFullYear(); I need to have the date appear with leading zeroes on the day and month … Read more

Format JavaScript date as yyyy-mm-dd

I have a date with the format Sun May 11,2014. How can I convert it to 2014-05-11 using JavaScript? function taskDate(dateMilli) { var d = (new Date(dateMilli) + ”).split(‘ ‘); d[2] = d[2] + ‘,’; return [d[0], d[1], d[2], d[3]].join(‘ ‘); } var datemilli = Date.parse(‘Sun May 11,2014’); console.log(taskDate(datemilli)); The code above gives me the … Read more

Where can I find documentation on formatting a date in JavaScript?

I noticed that JavaScript’s new Date() function is very smart in accepting dates in several formats. Xmas95 = new Date(“25 Dec, 1995 23:15:00”) Xmas95 = new Date(“2009 06 12,12:52:39”) Xmas95 = new Date(“20 09 2006,12:52:39”) I could not find documentation anywhere showing all the valid string formats while calling new Date() function. This is for … Read more