Java Date Create createDateString(long startDate, long endDate)

Here you can find the source of createDateString(long startDate, long endDate)

Description

create Date String

License

Apache License

Declaration

public static String createDateString(long startDate, long endDate) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Formatter;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static String createDateString(long startDate, long endDate) {
        GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault());

        StringBuffer dateLine = new StringBuffer(50);
        Formatter formatter = new Formatter(dateLine, Locale.ENGLISH);

        cal.setTimeInMillis(startDate);/*w w  w.jav a  2  s .  com*/

        dateLine.append("From ");
        formatter.format("%1$tH:%1$tM (GMT) %1$tb %1$te,%1$tY", cal);

        cal.setTimeInMillis(endDate);

        dateLine.append(" to ");
        formatter.format("%1$tH:%1$tM (GMT) %1$tb %1$te,%1$tY", cal);

        return dateLine.toString();
    }
}

Related

  1. createDate(int year, int month, int day)
  2. createDate(int year, int month, int day, int hour, int minute, int second)
  3. createDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
  4. createDateObject(Integer year, Integer month, Integer dayOfMonth, Integer hourOfDay, Integer minute, Integer second, Integer milissecond)
  5. createDates(int yy, int mm, int dd, int hh, int min, int ss)
  6. createDateTime(Date date, Date time)
  7. createDateTime(int year, int month, int day, int hour, int minute, int second, String timezone)
  8. createFutureDate()
  9. createFutureDate(int min)