convert date (long since 1970) in YYYY/MM/DD


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: convert date (long since 1970) in YYYY/MM/DD

  1. #1
    Nicolas Guest

    convert date (long since 1970) in YYYY/MM/DD


    Hello
    how is it possible to convert a date in long format since 1 january 1970
    to YYYY/MM/DD HH:MM:SS.


    Thank in advance,

    Nico

  2. #2
    Paul Clapham Guest

    Re: convert date (long since 1970) in YYYY/MM/DD

    One of the constructors for the java.util.Date class is defined as:

    Date(long date)
    Allocates a Date object and initializes it to represent the
    specified number of milliseconds since the standard base time known as "the
    epoch", namely January 1, 1970, 00:00:00 GMT.

    (copied from the Java documentation). That sounds like it should work for
    the first half of your question. If you want to display a date in a
    particular format, you might start by looking at the documentation for class
    java.text.SimpleDateFormat.

    Nicolas <nsylla@quallaby.fr> wrote in message
    news:3948fe86$1@news.devx.com...
    >
    > Hello
    > how is it possible to convert a date in long format since 1 january 1970
    > to YYYY/MM/DD HH:MM:SS.
    >
    >
    > Thank in advance,
    >
    > Nico




  3. #3
    Kesav Kumar Guest

    Re: convert date (long since 1970) in YYYY/MM/DD


    You can use SimpleDateFormat class which is in java.text package.

    You can convert any format of date to what ever the way you want.

    Eg.

    import java.text.*;
    import java.util.*;
    public class Test
    {
    public static void main(String args[])
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/DD HH:mm:ss");
    String date = fmt.format(Calendar.getInstance().getTime());
    System.out.println(date);
    }
    }

    "Nicolas" <nsylla@quallaby.fr> wrote:
    >
    >Hello
    >how is it possible to convert a date in long format since 1 january 1970
    >to YYYY/MM/DD HH:MM:SS.
    >
    >
    >Thank in advance,
    >
    >Nico




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center