Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static SimpleDateFormat serverSideDateFormator = null;

    public static String getTweleveHourTime(String timeToConvert) {
        String convertedTime = "";
        if (timeToConvert == null)
            return null;

        try {
            final Date dateObj = serverSideDateFormator.parse(timeToConvert);
            convertedTime = new SimpleDateFormat("K:mm a MM/dd/yyyy").format(dateObj);
        } catch (final ParseException e) {
            e.printStackTrace();
        }
        return convertedTime;
    }
}