List of usage examples for java.time LocalDateTime format
@Override
public String format(DateTimeFormatter formatter)
From source file:lumbermill.internal.aws.AWSV4SignerImpl.java
private String getCredentialScope(LocalDateTime now) { return now.format(DateTimeFormatter.BASIC_ISO_DATE) + SLASH + region + SLASH + service + AWS4_REQUEST; }
From source file:lumbermill.internal.aws.AWSV4SignerImpl.java
private String createStringToSign(String canonicalRequest, LocalDateTime now) { return AWS4_HMAC_SHA256 + now.format(BASIC_TIME_FORMAT) + RETURN + getCredentialScope(now) + RETURN + toBase16(hash(canonicalRequest.getBytes(Charsets.UTF_8))); }
From source file:hash.HashFilesController.java
private void generateChecksums(File file) { FileInputStream md5fis;//w w w . j a v a2 s . c o m String md5 = ""; try { md5fis = new FileInputStream(file); md5 = DigestUtils.md5Hex(md5fis); md5fis.close(); } catch (IOException ex) { Logger.getLogger(HashFilesController.class.getName()).log(Level.SEVERE, null, ex); } Checksum aChecksum = new Checksum(); aChecksum.setMD5Value(md5); ; aChecksum.setFileName(file.getName()); aChecksum.setFilePath(file.getPath()); DateTimeFormatter format = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT); LocalDateTime currentDateTime = LocalDateTime.now(); currentDateTime.format(format); aChecksum.setDateTimeGenerated(currentDateTime); SessionFactory sFactory = HibernateUtilities.getSessionFactory(); Session session = sFactory.openSession(); session.beginTransaction(); session.saveOrUpdate(aChecksum); CaseFile currentCase = (CaseFile) session.get(CaseFile.class, CreateCaseController.getCaseNumber()); currentCase.getMd5Details().add(aChecksum); aChecksum.setCaseFile(currentCase); session.getTransaction().commit(); session.close(); checksumTableView.getItems().add(aChecksum); System.out.println(aChecksum.getMD5Value()); System.out.println(aChecksum.getFileName()); System.out.println(aChecksum.getFilePath()); }
From source file:com.doctor.other.concurrent_hash_map_based_table.ConcurrentHashMapBasedTable.java
public boolean put(final String rowKey, final String columnKey, final LocalDateTime time, final T value) { return this.put(rowKey, columnKey, time.format(Util.timeFormatter), value); }
From source file:org.thingsboard.server.dao.audit.sink.ElasticsearchAuditLogSink.java
private String getIndexName(TenantId tenantId) { String indexName = indexPattern; if (indexName.contains(TENANT_PLACEHOLDER) && tenantId != null) { indexName = indexName.replace(TENANT_PLACEHOLDER, tenantId.getId().toString()); }//from w w w . j a va 2 s. c om if (indexName.contains(DATE_PLACEHOLDER)) { LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat); indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter)); } return indexName.toLowerCase(); }
From source file:org.obiba.mica.AbstractGitPersistableResource.java
private String createRestoreComment(CommitInfo commitInfo) { LocalDateTime date = LocalDateTime.parse(commitInfo.getDate().toString(), DateTimeFormatter.ofPattern("EEE MMM d HH:mm:ss zzz yyyy")); String formatted = date.format(DateTimeFormatter.ofPattern("MMM dd, yyyy h:mm a")); return String.format("Restored revision from '%s' (%s...)", formatted, commitInfo.getCommitId().substring(0, 9)); }
From source file:edu.zipcloud.cloudstreetmarket.core.services.StockProductServiceOfflineImpl.java
private void updateChartStockFromYahoo(StockProduct stock, ChartType type, ChartHistoSize histoSize, ChartHistoMovingAverage histoAverage, ChartHistoTimeSpan histoPeriod, Integer intradayWidth, Integer intradayHeight) { Preconditions.checkNotNull(stock, "stock must not be null!"); Preconditions.checkNotNull(type, "ChartType must not be null!"); String guid = AuthenticationUtil.getPrincipal().getUsername(); String token = usersConnectionRepository.getRegisteredSocialUser(guid).getAccessToken(); ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository(guid); Connection<Yahoo2> connection = connectionRepository.getPrimaryConnection(Yahoo2.class); if (connection != null) { byte[] yahooChart = connection.getApi().financialOperations().getYahooChart(stock.getId(), type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight, token); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HHmm"); LocalDateTime dateTime = LocalDateTime.now(); String formattedDateTime = dateTime.format(formatter); // "1986-04-08_1230" String imageName = stock.getId().toLowerCase() + "_" + type.name().toLowerCase() + "_" + formattedDateTime + ".png"; String pathToYahooPicture = env.getProperty("pictures.yahoo.path").concat(File.separator + imageName); try {/*ww w .jav a 2 s . c o m*/ Path newPath = Paths.get(pathToYahooPicture); Files.write(newPath, yahooChart, StandardOpenOption.CREATE); } catch (IOException e) { throw new Error("Storage of " + pathToYahooPicture + " failed", e); } ChartStock chartStock = new ChartStock(stock, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight, pathToYahooPicture); chartStockRepository.save(chartStock); } }
From source file:edu.zipcloud.cloudstreetmarket.api.services.StockProductServiceOnlineImpl.java
private void updateChartStockFromYahoo(StockProduct stock, ChartType type, ChartHistoSize histoSize, ChartHistoMovingAverage histoAverage, ChartHistoTimeSpan histoPeriod, Integer intradayWidth, Integer intradayHeight) { Preconditions.checkNotNull(stock, "stock must not be null!"); Preconditions.checkNotNull(type, "ChartType must not be null!"); String guid = AuthenticationUtil.getPrincipal().getUsername(); SocialUser socialUser = usersConnectionRepository.getRegisteredSocialUser(guid); if (socialUser == null) { return;//w w w. j a v a 2s .c om } String token = socialUser.getAccessToken(); Connection<Yahoo2> connection = connectionRepository.getPrimaryConnection(Yahoo2.class); if (connection != null) { byte[] yahooChart = connection.getApi().financialOperations().getYahooChart(stock.getId(), type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight, token); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HHmm"); LocalDateTime dateTime = LocalDateTime.now(); String formattedDateTime = dateTime.format(formatter); // "1986-04-08_1230" String imageName = stock.getId().toLowerCase() + "_" + type.name().toLowerCase() + "_" + formattedDateTime + ".png"; String pathToYahooPicture = env.getProperty("user.home").concat(env.getProperty("pictures.yahoo.path")) .concat(File.separator + imageName); try { Path newPath = Paths.get(pathToYahooPicture); Files.write(newPath, yahooChart, StandardOpenOption.CREATE); } catch (IOException e) { throw new Error("Storage of " + pathToYahooPicture + " failed", e); } ChartStock chartStock = new ChartStock(stock, type, histoSize, histoAverage, histoPeriod, intradayWidth, intradayHeight, pathToYahooPicture); chartStockRepository.save(chartStock); } }
From source file:org.pentaho.platform.web.http.api.resources.RepositoryFileStreamProvider.java
public OutputStream getOutputStream() throws Exception { String tempOutputFilePath = outputFilePath; String extension = RepositoryFilenameUtils.getExtension(tempOutputFilePath); if ("*".equals(extension)) { //$NON-NLS-1$ tempOutputFilePath = tempOutputFilePath.substring(0, tempOutputFilePath.lastIndexOf('.')); if (appendDateFormat != null) { try { LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(appendDateFormat); String formattedDate = now.format(formatter); tempOutputFilePath += formattedDate; } catch (Exception e) { logger.warn("Unable to calculate current date: " + e.getMessage()); }/*from w w w. j a va 2s . co m*/ } if (streamingAction != null) { String mimeType = streamingAction.getMimeType(null); if (mimeType != null && MimeHelper.getExtension(mimeType) != null) { tempOutputFilePath += MimeHelper.getExtension(mimeType); } } } RepositoryFileOutputStream outputStream = new RepositoryFileOutputStream(tempOutputFilePath, autoCreateUniqueFilename, true); outputStream.addListener(this); return outputStream; }
From source file:com.jubination.io.chatbot.backend.service.core.LMSUpdater.java
public boolean createLead(User user) throws IOException { String responseText = null;/*from w w w . j a v a2 s . c om*/ Document doc = null; CloseableHttpResponse response = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; InputSource is; try { //requesting exotel to initiate call CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("http://188.166.253.79/save_enquiry"); List<NameValuePair> formparams = new ArrayList<>(); formparams.add(new BasicNameValuePair("form_data[0][email_id]", user.getEmail())); formparams.add(new BasicNameValuePair("form_data[0][full_name]", user.getName())); formparams.add(new BasicNameValuePair("form_data[0][contact_no]", user.getPhone())); formparams.add(new BasicNameValuePair("form_data[0][city]", user.getCountry())); formparams.add(new BasicNameValuePair("form_data[0][ip]", "na")); if (user.getFbId() != null) { formparams.add(new BasicNameValuePair("form_data[0][campaign_id]", "162")); formparams.add(new BasicNameValuePair("form_data[0][source]", "fb-chatbot")); } else { formparams.add(new BasicNameValuePair("form_data[0][campaign_id]", "161")); formparams.add(new BasicNameValuePair("form_data[0][source]", "web-chatbot")); } formparams.add(new BasicNameValuePair("form_data[0][step_2]", "no")); formparams.add(new BasicNameValuePair("form_data[0][step_2_created_at]", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); LocalDateTime backdate = LocalDateTime.of(2013, Month.JANUARY, 1, 0, 0); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); formparams.add(new BasicNameValuePair("form_data[0][step_2_inform_at]", backdate.format(formatter))); formparams.add(new BasicNameValuePair("form_data[0][chat_id]", user.getSesId())); for (Entry<String, Boolean> trigger : user.getTriggers().entrySet()) { formparams.add(new BasicNameValuePair("form_data[0][chat_" + trigger.getKey() + "]", trigger.getValue().toString())); } UrlEncodedFormEntity uEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8); httpPost.setEntity(uEntity); response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); responseText = EntityUtils.toString(entity, "UTF-8"); } catch (IOException | ParseException | DOMException e) { e.printStackTrace(); } finally { if (response != null) { response.close(); } } System.out.println(responseText); return responseText != null; }