• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

Setting a timestamp to a file creating in memory [duplicate]

April 10, 2020 by

Questions › Setting a timestamp to a file creating in memory [duplicate]
0
Vote Up
Vote Down
Garmaine asked 4 years ago
This question already has answers here:
http://stackoverflow.com//questions/5683728/convert-java-util-date-to-string”>Convert java.util.Date to String (18 answers)
http://stackoverflow.com//questions/11046053/how-to-format-date-string-in-java”>How to format date string in java? [duplicate] (3 answers)
Closed 3 hours ago.

I need my CSV file name to have a constant name + the exact time and date when file has been created.

For example – constant(my_file) + “_20200411_02:00”

    private final CsvFile csvFile;
public static final String  CSV_NAME = "file_name";

private List<String> formattedEntries() {
    String cvs_separator = ";";
    return csvFile.getEntries()
            .stream()
            .map(v -> v.getRange() + cvs_separator + v.getPersonNumber() + cvs_separator + v.getFieldInput())
            .collect(Collectors.toList());
}

public void writeToCsv() {
    File csvOutputFile = new File(CSV_NAME);
    try (PrintWriter pw = new PrintWriter(csvOutputFile)) {
        formattedEntries().forEach(pw::println);
    } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
    }
}

The code above formatting each object and adding modified object to list, then calling PrintWriter to print the file and as you can see the constant is there but the mission of mine is to have the exact time and date added.

Would appreciate any help

Thank you

Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: csv, date, file, java, time

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Copyright © 2023