Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    public static String getTimeString(Calendar calendar) {
        if (calendar == null)
            return "";
        String hourString = String.format("%1$02d", calendar.get(Calendar.HOUR_OF_DAY));
        String minuteString = String.format("%1$02d", calendar.get(Calendar.MINUTE));
        StringBuilder dateStringBuilder = new StringBuilder();
        dateStringBuilder.append(hourString).append(":");
        dateStringBuilder.append(minuteString);
        return dateStringBuilder.toString();
    }
}