Search in sources :

Example 91 with DateFormat

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;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Label(org.apache.wicket.markup.html.basic.Label) SimpleDateFormat(java.text.SimpleDateFormat)

Example 92 with DateFormat

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;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Label(org.apache.wicket.markup.html.basic.Label) SimpleDateFormat(java.text.SimpleDateFormat)

Example 93 with DateFormat

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);
}
Also used : Locale(java.util.Locale) DateFormat(java.text.DateFormat)

Example 94 with DateFormat

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));
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat)

Example 95 with DateFormat

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));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

DateFormat (java.text.DateFormat)646 SimpleDateFormat (java.text.SimpleDateFormat)486 Date (java.util.Date)315 ParseException (java.text.ParseException)132 Calendar (java.util.Calendar)78 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)48 IOException (java.io.IOException)43 File (java.io.File)31 HashMap (java.util.HashMap)27 GregorianCalendar (java.util.GregorianCalendar)24 TimeZone (java.util.TimeZone)23 Locale (java.util.Locale)18 Timestamp (java.sql.Timestamp)17 List (java.util.List)14 InputStream (java.io.InputStream)12 DateTime (org.joda.time.DateTime)11 Map (java.util.Map)10 Matcher (java.util.regex.Matcher)8 TestBean (org.springframework.tests.sample.beans.TestBean)8