Convert Date to String.. (Java)

Gua sempet beberapa jam bingung buat nampilin data yang di database tipenya date ditampilkan ke jsp yang harus tipe-nya string.. Berikut ini gua kasih code yang biasa gua tulis di file view-nya:

import java.util.*;
import java.text.*;
...

    public Date getValuationDate()
    {
        return valuationDate;
    }

    public void setValuationDate(Date valuationDate)
    {
        this.valuationDate = valuationDate;
    }

    public String getSQLDateFormat() {
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
        return sdf.format(getValuationDate());
    }

Semoga bermanfaat..😀


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s