Changeset 30860
- Timestamp:
- 2016-10-13T13:08:33+13:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
r30830 r30860 23 23 import java.io.UnsupportedEncodingException; 24 24 import java.net.URLEncoder; 25 import java.text.DateFormat; 25 26 import java.text.SimpleDateFormat; 26 27 import java.util.ArrayList; … … 513 514 } 514 515 516 public static final int TS_SECS = 0; 517 public static final int TS_MILLISECS = 1; 518 public static final int F_DATE = 0; 519 public static final int F_TIME = 1; 520 public static final int F_DATETIME = 2; 521 public static final int F_DAYSAGO = 3; 522 523 public static String formatTimeStamp(String timestamp, int ts_type, int format_type, String lang) { 524 try { 525 long ts = Long.parseLong(timestamp); 526 if (ts_type == TS_SECS) { 527 ts = ts * 1000; 528 } 529 if (format_type == F_DAYSAGO) { 530 long current_time = new Date().getTime(); 531 long days = (current_time - ts)/86400000; 532 return String.valueOf(days); 533 } 534 Date d = new Date(ts); 535 DateFormat df; 536 switch (format_type) { 537 case F_DATE: 538 df = DateFormat.getDateInstance(DateFormat.DEFAULT, new Locale(lang)); 539 break; 540 case F_TIME: 541 df = DateFormat.getTimeInstance(DateFormat.DEFAULT, new Locale(lang)); 542 break; 543 case F_DATETIME: 544 df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, new Locale(lang)); 545 break; 546 default: 547 df = DateFormat.getDateInstance(DateFormat.DEFAULT, new Locale(lang)); 548 break; 549 } 550 551 return df.format(d); 552 } catch (Exception e) { 553 554 return timestamp + e.getMessage(); 555 } 556 557 } 515 558 public static String getDetailFromDate(String date, String detail, String lang) 516 559 {
Note:
See TracChangeset
for help on using the changeset viewer.