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);
}
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;
}
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);
}
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';
}
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;
}
Aggregations