Java Calendar Time setTime(final Calendar calendat, final String[] test)

Here you can find the source of setTime(final Calendar calendat, final String[] test)

Description

set Time

License

Open Source License

Declaration

private static Calendar setTime(final Calendar calendat, final String[] test) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    private static Calendar setTime(final Calendar calendat, final String[] test) {
        if (test.length == 3) {
            calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim()));
            calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim()));
            calendat.set(Calendar.SECOND, Integer.parseInt(test[2].trim()));
        }//from  w  w w.j a  va  2 s .c o m
        if (test.length == 2) {
            calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim()));
            calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim()));
            calendat.set(Calendar.SECOND, 0);
        }
        return calendat;
    }
}

Related

  1. roundTime(double dt, Calendar tmp)
  2. sameTime(Calendar one, Calendar two)
  3. setDateTimeByString(Calendar theDateTime, String str)
  4. setTime(Calendar cal, int h, int m, int s, int ms)
  5. setTime(Calendar cal, String time)
  6. setTimeFrom(Calendar c)
  7. setTimeTo0(final Calendar calendar)
  8. setTimeToMidnight(GregorianCalendar c)
  9. setTimeToMinOrMax(Calendar cal, boolean max)