Java SimpleDateFormat timezone parsing -
i'm curious how java's simpledateformat decides when increment/decrement passed in time based on timezone it's set to.
let's have date 06/04/2013. set timezone 1 far away me(i'm in gmt-5). let's use gmt+8.
i call
simpledateformat df = new simpledateformat( "m/d/yy" ); df.settimezone( timezone.gettimezone( "gmt+8" ) ); df.parse( enddate ) // returns 06/**03**/2013 //enddate string
it returns 06/03/2013. why decrement it?
edit: i'm asking reference point java uses knock date 6/3 if set gmt+8. there's logic says hey i'm not on current timezone let's change it. since i'm passing in string don't see be.
i assume default if don't provide timezone in string default gmt.
you're in gmt-5, , you're parsing string representing moment in gmt+8 time zone.
so, date 06/04/2013
in fact 06/04/2013 00:00 gmt+8
. date @ gmt, have subtract 8 hours: 06/03/2013 16:00 gmt
. , date @ gmt-5, have subtract 5 hours: 06/03/2013 11:00 gmt-5
.
all these strings different representations of same moment.
Comments
Post a Comment