Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset
Comments Off

Java: How to format dates using Date and Calendar objects

Java: How to format dates using  Date and Calendar objects
{filelink=5531}

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class FormatDate
{
  public static void main(String[] arg) {
    Locale f_fr = new Locale("fr", "FR"), f_us=new Locale("en", "US"), f_es = new Locale("es", "ES");
    Calendar c = Calendar.getInstance();
    c.set(1954, 03, 15);
    Date date = c.getTime();
    DateFormat fd_fr = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
        DateFormat.MEDIUM, f_fr)
    , fd_us = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, f_us)
    , fd_es = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, f_es);
    System.out.println("French Format: " + fd_fr.format(date));
    System.out.println("US English Format: " + fd_us.format(date));
    System.out.println("Spanish Format: " + fd_es.format(date));
  }
}

Users who found this page were searching for:

  • java underline text
  • python iterate over dictionary keys
  • python file operation exception
  • program for ftp which create, transfer and delete file in java
  • java how to println space
  • raise IOError
  • python programming percentages
  • format date using java calendar
  • python iterate tuple
  • selection structure examples in perl

No comments yet.

Leave a Comment

Switch to our mobile site