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

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:

  • selection structure examples in perl
  • how to format a calendar object
  • python iterate over dictionary keys
  • python file operation exception
  • raise IOError
  • java underline text
  • python iterate tuple
  • perl selection examples
  • java how to println space
  • python programming percentages

No comments yet.

Leave a Comment

Switch to our mobile site