List of usage examples for org.joda.time.format ISODateTimeFormat basicDateTimeNoMillis
public static DateTimeFormatter basicDateTimeNoMillis()
From source file:org.opendaylight.iotdm.client.util.Onem2mDateTime.java
License:Open Source License
public static String getCurrDateTime() { DateTime dt = new DateTime(DateTimeZone.UTC); DateTimeFormatter fmt = ISODateTimeFormat.basicDateTimeNoMillis(); return fmt.print(dt); }
From source file:org.opendaylight.iotdm.client.util.Onem2mDateTime.java
License:Open Source License
private static DateTime stringToDate(String dateTimeString) { DateTime dt = null;//from w w w . j a v a 2 s . co m DateTimeFormatter fmt = ISODateTimeFormat.basicDateTimeNoMillis(); try { dt = fmt.parseDateTime(dateTimeString); } catch (IllegalArgumentException e) { return null; } return dt; }
From source file:org.opendaylight.iotdm.client.util.Onem2mDateTime.java
License:Open Source License
public static boolean isValidDateTime(String dateTimeString) { DateTimeFormatter fmt = ISODateTimeFormat.basicDateTimeNoMillis(); try {//from w w w. j a v a 2 s . com DateTime dt = fmt.parseDateTime(dateTimeString); } catch (IllegalArgumentException e) { return false; } return true; }
From source file:org.schedoscope.export.ftp.outputformat.FtpUploadOutputFormat.java
License:Apache License
/** * A method to configure the output format. * * @param job The job object.//from w ww . ja v a 2 s. c o m * @param tableName The Hive input table name * @param printHeader A flag indicating to print a csv header or not. * @param delimiter The delimiter to use for separating the records (CSV) * @param fileType The file type (csv / json) * @param codec The compresson codec (none / gzip / bzip2) * @param ftpEndpoint The (s)ftp endpoint. * @param ftpUser The (s)ftp user * @param ftpPass The (s)ftp password or sftp passphrase * @param keyFile The private ssh key file * @param filePrefix An optional file prefix * @param passiveMode Passive mode or not (only ftp) * @param userIsRoot User dir is root or not * @param cleanHdfsDir Clean up HDFS temporary files. * @throws Exception Is thrown if an error occurs. */ public static void setOutput(Job job, String tableName, boolean printHeader, String delimiter, FileOutputType fileType, FileCompressionCodec codec, String ftpEndpoint, String ftpUser, String ftpPass, String keyFile, String filePrefix, boolean passiveMode, boolean userIsRoot, boolean cleanHdfsDir) throws Exception { Configuration conf = job.getConfiguration(); String tmpDir = conf.get("hadoop.tmp.dir"); String localTmpDir = RandomStringUtils.randomNumeric(10); setOutputPath(job, new Path(tmpDir, FTP_EXPORT_TMP_OUTPUT_PATH + localTmpDir)); conf.setInt(FileOutputCommitter.FILEOUTPUTCOMMITTER_ALGORITHM_VERSION, 2); conf.set(FTP_EXPORT_TABLE_NAME, tableName); conf.set(FTP_EXPORT_ENDPOINT, ftpEndpoint); conf.set(FTP_EXPORT_USER, ftpUser); if (ftpPass != null) { conf.set(FTP_EXPORT_PASS, ftpPass); } if (delimiter != null) { if (delimiter.length() != 1) { throw new IllegalArgumentException("delimiter must be exactly 1 char"); } conf.set(FTP_EXPORT_CVS_DELIMITER, delimiter); } if (keyFile != null && Files.exists(Paths.get(keyFile))) { // Uploader.checkPrivateKey(keyFile); String privateKey = new String(Files.readAllBytes(Paths.get(keyFile)), StandardCharsets.US_ASCII); conf.set(FTP_EXPORT_KEY_FILE_CONTENT, privateKey); } conf.setBoolean(FTP_EXPORT_PASSIVE_MODE, passiveMode); conf.setBoolean(FTP_EXPORT_USER_IS_ROOT, userIsRoot); conf.setBoolean(FTP_EXPORT_CLEAN_HDFS_DIR, cleanHdfsDir); DateTimeFormatter fmt = ISODateTimeFormat.basicDateTimeNoMillis(); String timestamp = fmt.print(DateTime.now(DateTimeZone.UTC)); conf.set(FTP_EXPORT_FILE_PREFIX, filePrefix + "-" + timestamp + "-"); if (printHeader) { conf.setStrings(FTP_EXPORT_HEADER_COLUMNS, setCSVHeader(conf)); } conf.set(FTP_EXPORT_FILE_TYPE, fileType.toString()); if (codec.equals(FileCompressionCodec.gzip)) { setOutputCompressorClass(job, GzipCodec.class); } else if (codec.equals(FileCompressionCodec.bzip2)) { setOutputCompressorClass(job, BZip2Codec.class); } else if (codec.equals(FileCompressionCodec.none)) { extension = ""; } }
From source file:propel.core.utils.StringUtils.java
License:Open Source License
/** * Returns ISO standard and other frequently used date/time parsers */// w w w . j a v a 2s . c o m private static DateTimeParser[] createCommonDateTimeParsers() { return new DateTimeParser[] { ISODateTimeFormat.basicDateTimeNoMillis().getParser(), // yyyyMMdd'T'HHmmssZ ISODateTimeFormat.basicDateTime().getParser(), // yyyyMMdd'T'HHmmss.SSSZ ISODateTimeFormat.dateHourMinuteSecondFraction().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS (only 3 ms positions used though) ISODateTimeFormat.dateTimeNoMillis().getParser(), // yyyy-MM-dd'T'HH:mm:ssZZ ISODateTimeFormat.dateTime().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSZZ (ISO 8601) DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z").getParser(), // RFC 2822 DateTimeFormat.forPattern("yyyy/MM/dd").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd HH:mm").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss.SSSSSSSSS").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd HH:mm").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS").getParser(), DateTimeFormat.forPattern("yyyy.MM.dd").getParser(), DateTimeFormat.forPattern("yyyy.MM.dd HH:mm").getParser(), DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss").getParser(), DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss.SSSSSSSSS").getParser(), DateTimeFormat.forPattern("HH:mm").getParser(), DateTimeFormat.forPattern("HH:mm:ss").getParser(), DateTimeFormat.forPattern("HH:mm:ss.SSSSSSSSS").getParser() }; }
From source file:se.jguru.nazgul.core.reflection.api.conversion.registry.helpers.MultiConverter.java
License:Apache License
@Converter(conditionalConversionMethod = "isBasicDateTimeNoMillisFormat") public DateTime convertToDateTime(final String aString) { return DateTime.parse(aString, ISODateTimeFormat.basicDateTimeNoMillis()); }
From source file:se.jguru.nazgul.core.reflection.api.conversion.registry.helpers.MultiConverter.java
License:Apache License
public boolean isBasicDateTimeNoMillisFormat(final String aString) { try {/* w w w.j a va 2s .c o m*/ DateTime.parse(aString, ISODateTimeFormat.basicDateTimeNoMillis()); } catch (Exception e) { return false; } return true; }
From source file:se.jguru.nazgul.core.reflection.api.conversion.registry.helpers.MultiConverter.java
License:Apache License
public DateTime nonAnnotatedConverterMethod(final String aString) { return DateTime.parse(aString, ISODateTimeFormat.basicDateTimeNoMillis()); }