com.pamarin.income.controller.DateFormat.java Source code

Java tutorial

Introduction

Here is the source code for com.pamarin.income.controller.DateFormat.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pamarin.income.controller;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 *
 * @author anonymous
 */
@Component
@Scope("request")
public class DateFormat {

    public String format(Date date, String pattern) {
        Format format = new SimpleDateFormat(pattern, new Locale("th", "TH"));
        return format.format(date);
    }
}