Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgChangelog.java @ 211:644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 29 Apr 2011 02:37:52 +0200 |
| parents | e2115da4cf6a |
| children | 883300108179 |
comparison
equal
deleted
inserted
replaced
| 210:6a2481866491 | 211:644ee58c9f16 |
|---|---|
| 138 } | 138 } |
| 139 | 139 |
| 140 public Date date() { | 140 public Date date() { |
| 141 return time; | 141 return time; |
| 142 } | 142 } |
| 143 | |
| 144 /** | |
| 145 * @return time zone value, as is, positive for Western Hemisphere. | |
| 146 */ | |
| 147 public int timezone() { | |
| 148 return timezone; | |
| 149 } | |
| 143 | 150 |
| 144 public String dateString() { | 151 public String dateString() { |
| 145 // XXX keep once formatted? Perhaps, there's faster way to set up calendar/time zone? | 152 // XXX keep once formatted? Perhaps, there's faster way to set up calendar/time zone? |
| 146 StringBuilder sb = new StringBuilder(30); | 153 StringBuilder sb = new StringBuilder(30); |
| 147 Formatter f = new Formatter(sb, Locale.US); | 154 Formatter f = new Formatter(sb, Locale.US); |
| 148 TimeZone tz = TimeZone.getTimeZone("GMT"); | 155 TimeZone tz = TimeZone.getTimeZone(TimeZone.getAvailableIDs(timezone * 1000)[0]); |
| 149 // apparently timezone field records number of seconds time differs from UTC, | 156 // apparently timezone field records number of seconds time differs from UTC, |
| 150 // i.e. value to substract from time to get UTC time. Calendar seems to add | 157 // i.e. value to substract from time to get UTC time. Calendar seems to add |
| 151 // timezone offset to UTC, instead, hence sign change. | 158 // timezone offset to UTC, instead, hence sign change. |
| 152 tz.setRawOffset(timezone * -1000); | 159 // tz.setRawOffset(timezone * -1000); |
| 153 Calendar c = Calendar.getInstance(tz, Locale.US); | 160 Calendar c = Calendar.getInstance(tz, Locale.US); |
| 154 c.setTime(time); | 161 c.setTime(time); |
| 155 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", c); | 162 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", c); |
| 156 return sb.toString(); | 163 return sb.toString(); |
| 157 } | 164 } |
