Java Date to String datetostring(Date dateInst)

Here you can find the source of datetostring(Date dateInst)

Description

datetostring

License

LGPL

Declaration

public static String datetostring(Date dateInst) throws ParseException 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static String datetostring(Date dateInst) throws ParseException {
        //String dateTime = "2002-02-02T22:22:22Z";
        //String dateTime = "2002-02-02";
        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        String dtstring = formatter.format(dateInst);

        return dtstring;
    }//from w w  w.  ja va 2  s .  c  o m
}

Related

  1. DateToString(Date date, String pattern)
  2. dateToString(Date date, String pattern)
  3. dateToString(Date date, String pattern)
  4. dateToString(Date date, String sPattern)
  5. dateToString(Date date, String strFormat)
  6. DateToString(Date Expression)
  7. dateToString(Date fecha)
  8. DateToString(Date fecha, String formato)
  9. dateToString(Date pd_fecha)