build Time String - Android java.util

Android examples for java.util:Time

Description

build Time String

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static String buildTimeString(int[] time) {
        // Minute + 100 to display HH::mm instead of H:m
        return Integer.toString(time[0]) + ":"
                + Integer.toString((time[1]) + 100).substring(1);
    }//from   ww w  .ja  v a2 s.c o  m

    public static String buildTimeString(Calendar calendarTime) {
        // Minute + 100 to display HH::mm instead of H:m
        return Integer.toString(calendarTime.get(Calendar.HOUR_OF_DAY))
                + ":"
                + Integer.toString(calendarTime.get(Calendar.MINUTE) + 100)
                        .substring(1);
    }
}

Related Tutorials