Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset
Comments Off

Java: How to format dates using Date and Calendar objects

Your ads will be inserted here by

Easy AdSense.

Please go to the plugin admin page to paste your ad code.

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:

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

No comments yet.

Leave a Comment

Switch to our mobile site