Simple example to show how to use Date Formatting in Java
Given that 1119280000000L is reoughly the number of milliseconds from Jan 1, 1970, to June 20, 2005, and that you want to print that date in German, using LONG style such that “June” will be displayed as “Juni”.
import java.text.*; import java.util.*; //import java.date.*;// There is such package defined in Java!! public class DateFormatExample { public static void main(String[] args){ Date d = new Date(1119280000000L); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.GERMANY); System.out.println(df.format(d)); } }
Comments(0)