Search in sources :

Example 11 with SimpleDateFormat

use of com.ibm.icu.text.SimpleDateFormat in project error-prone by google.

the class MisusedWeekYearPositiveCases2 method testConstructors.

void testConstructors() {
    // BUG: Diagnostic contains: new SimpleDateFormat("yyyy-MM-dd")
    SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
    // BUG: Diagnostic contains:
    sdf = new SimpleDateFormat("YYYY-MM-dd", DateFormatSymbols.getInstance());
    // BUG: Diagnostic contains:
    sdf = new SimpleDateFormat("YYYY-MM-dd", DateFormatSymbols.getInstance(), ULocale.CANADA);
    // BUG: Diagnostic contains:
    sdf = new SimpleDateFormat("YYYY-MM-dd", Locale.getDefault());
    // BUG: Diagnostic contains:
    sdf = new SimpleDateFormat("YYYY-MM-dd", "", ULocale.CANADA);
    // BUG: Diagnostic contains:
    sdf = new SimpleDateFormat("YYYY-MM-dd", ULocale.CANADA);
}
Also used : SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat)

Example 12 with SimpleDateFormat

use of com.ibm.icu.text.SimpleDateFormat in project webtools.sourceediting by eclipse.

the class DateUtil method now.

public static String now() {
    // just calculate once, so whole run as same timestamp
    if (DateUtil.now == null) {
        DateFormat format = new SimpleDateFormat("yyyy'-'MM'-'dd'-'kk'-'mm'-'ss");
        Calendar calendar = Calendar.getInstance();
        Date today = calendar.getTime();
        DateUtil.now = format.format(today);
    }
    return DateUtil.now;
}
Also used : SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) DateFormat(com.ibm.icu.text.DateFormat) Calendar(java.util.Calendar) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) Date(java.util.Date)

Example 13 with SimpleDateFormat

use of com.ibm.icu.text.SimpleDateFormat in project nutch by apache.

the class CommonCrawlDataDumper method constructNewStream.

private void constructNewStream(File outputDir) throws IOException {
    String archiveName = new SimpleDateFormat("yyyyMMddhhmm'.tar.gz'").format(new Date());
    LOG.info("Creating a new gzip archive: " + archiveName);
    fileOutput = new FileOutputStream(new File(outputDir + File.separator + archiveName));
    bufOutput = new BufferedOutputStream(fileOutput);
    gzipOutput = new GzipCompressorOutputStream(bufOutput);
    tarOutput = new TarArchiveOutputStream(gzipOutput);
    tarOutput.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
}
Also used : GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) FileOutputStream(java.io.FileOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) SequenceFile(org.apache.hadoop.io.SequenceFile) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) Date(java.util.Date)

Example 14 with SimpleDateFormat

use of com.ibm.icu.text.SimpleDateFormat in project es6draft by anba.

the class DateTimeFormatConstructor method defaultHourFormat.

/**
 * Retrieve the default hour format character for the supplied locale.
 *
 * @param locale
 *            the locale
 * @return the hour format character
 * @see <a href="http://bugs.icu-project.org/trac/ticket/9997">ICU bug 9997</a>
 */
private static char defaultHourFormat(ULocale locale) {
    // Use short time format, just as ICU4J does internally. And as suggested in
    // <http://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems>.
    SimpleDateFormat df = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT, locale);
    Skeleton skeleton = Skeleton.fromPattern(df.toPattern());
    if (skeleton.has(DateField.Hour)) {
        return skeleton.getSymbol(DateField.Hour);
    }
    return 'H';
}
Also used : Skeleton(com.github.anba.es6draft.runtime.objects.intl.DateFieldSymbolTable.Skeleton) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat)

Example 15 with SimpleDateFormat

use of com.ibm.icu.text.SimpleDateFormat in project es6draft by anba.

the class DateTimeFormatObject method createDateFormat.

private DateFormat createDateFormat() {
    ULocale locale = ULocale.forLanguageTag(this.locale);
    // calendar and numberingSystem are already handled in language-tag
    // assert locale.getKeywordValue("calendar").equals(calendar);
    // assert locale.getKeywordValue("numbers").equals(numberingSystem);
    SimpleDateFormat dateFormat = new SimpleDateFormat(pattern.get(), locale);
    if (timeZone != null) {
        dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone));
    }
    Calendar calendar = dateFormat.getCalendar();
    if (calendar instanceof GregorianCalendar) {
        // format uses a proleptic Gregorian calendar with no year 0
        GregorianCalendar gregorian = (GregorianCalendar) calendar;
        gregorian.setGregorianChange(new Date(Long.MIN_VALUE));
    }
    return dateFormat;
}
Also used : ULocale(com.ibm.icu.util.ULocale) Calendar(com.ibm.icu.util.Calendar) GregorianCalendar(com.ibm.icu.util.GregorianCalendar) GregorianCalendar(com.ibm.icu.util.GregorianCalendar) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

SimpleDateFormat (com.ibm.icu.text.SimpleDateFormat)16 Date (java.util.Date)8 DateFormat (com.ibm.icu.text.DateFormat)4 TemplateBuffer (org.eclipse.jface.text.templates.TemplateBuffer)4 Test (org.junit.Test)4 Calendar (java.util.Calendar)3 ULocale (com.ibm.icu.util.ULocale)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 Locale (java.util.Locale)2 SequenceFile (org.apache.hadoop.io.SequenceFile)2 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Skeleton (com.github.anba.es6draft.runtime.objects.intl.DateFieldSymbolTable.Skeleton)1 Context (com.github.jknack.handlebars.Context)1 Handlebars (com.github.jknack.handlebars.Handlebars)1 Template (com.github.jknack.handlebars.Template)1 FileTemplateLoader (com.github.jknack.handlebars.io.FileTemplateLoader)1