use of java.text.DateFormat in project gitblit by gitblit.
the class WicketUtils method createTimeLabel.
public static Label createTimeLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {
String format = GitBlitWebApp.get().settings().getString(Keys.web.timeFormat, "HH:mm");
DateFormat df = new SimpleDateFormat(format);
if (timeZone == null) {
timeZone = GitBlitWebApp.get().getTimezone();
}
df.setTimeZone(timeZone);
String timeString;
if (date.getTime() == 0) {
timeString = "--";
} else {
timeString = df.format(date);
}
String title = timeUtils.timeAgo(date);
Label label = new Label(wicketId, timeString);
if (!StringUtils.isEmpty(title)) {
WicketUtils.setHtmlTooltip(label, title);
}
return label;
}
use of java.text.DateFormat in project gitblit by gitblit.
the class WicketUtils method createTimestampLabel.
public static Label createTimestampLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {
String format = GitBlitWebApp.get().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy HH:mm Z");
DateFormat df = new SimpleDateFormat(format);
if (timeZone == null) {
timeZone = GitBlitWebApp.get().getTimezone();
}
df.setTimeZone(timeZone);
String dateString;
if (date.getTime() == 0) {
dateString = "--";
} else {
dateString = df.format(date);
}
String title = null;
if (date.getTime() <= System.currentTimeMillis()) {
// past
title = timeUtils.timeAgo(date);
}
Label label = new Label(wicketId, dateString);
if (!StringUtils.isEmpty(title)) {
WicketUtils.setHtmlTooltip(label, title);
}
return label;
}
use of java.text.DateFormat in project j2objc by google.
the class DateFormatTest method testAFDateFormat.
// Issue 774: ArrayIndexOutOfBoundsException thrown with AF locale.
public void testAFDateFormat() {
long timestamp = 1234;
Locale locale = new Locale("en", "AF");
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
String result = dateFormat.format(timestamp);
assertNotNull(result);
}
use of java.text.DateFormat in project j2objc by google.
the class SimpleDateFormatTest method test_sl_dates.
// http://b/17431155
public void test_sl_dates() throws Exception {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("sl"));
df.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("1. 01. 70", df.format(0L));
}
use of java.text.DateFormat in project j2objc by google.
the class SimpleDateFormatTest method formatDate.
private String formatDate(Locale l, String fmt, TimeZone tz) {
DateFormat dateFormat = new SimpleDateFormat(fmt, l);
dateFormat.setTimeZone(tz);
return dateFormat.format(new Date(0));
}
Aggregations