Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to convert date to different format

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to convert date to different format

    Hi,
    Could somebody tell me how I can convert date that I am reading from txt file to a different format for example from 'DD,MM,YYYY HH:MM:SS' to 'MM/DD/YYYY HH:MM:SS' in my new CSV file. This is part of my code only to give an idea what I am trying:

    public void writeToTXT(BufferedWriter writer) throws IOException {
    writer.write(writeCSV(datetime) + columnDelimiter);
    writer.write(writeCSV(name) + columnDelimiter);
    writer.write(writeCSV(surname) + columnDelimiter);
    writer.newLine();
    }

    Thanks in advance


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: How to convert date to different format


  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to convert date to different format

    Hi
    Thanks for the reply. I tried to use the SimpleDateFormat but this is still not working for me. Could somebody suggest how to make this line converting my date to the right format
    writer.write(writeCSV(new SimpleDateFormat("DD-MM-YYYY 00:00:00").format(datetime)) + columnDelimiter);

    Thanks

Similar Threads

  1. Java Date Format in Date Object
    By Ashr Raza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 13th, 2012, 10:47 AM
  2. Working out the day from numeric date (dd/mm/yy format).
    By ShaunB in forum Java Theory & Questions
    Replies: 6
    Last Post: April 23rd, 2011, 09:55 PM
  3. date format
    By arunjib in forum Java Theory & Questions
    Replies: 4
    Last Post: March 12th, 2011, 01:42 PM
  4. How Convert a Byte array to a image format
    By perlWhite in forum Algorithms & Recursion
    Replies: 7
    Last Post: February 19th, 2011, 03:16 PM
  5. a litle help on how to convert date to day
    By george in forum Algorithms & Recursion
    Replies: 6
    Last Post: March 18th, 2010, 07:18 PM