Java Calendar Time timestampToCalendar(String timestamp)

Here you can find the source of timestampToCalendar(String timestamp)

Description

timestamp To Calendar

License

Open Source License

Declaration

public static Calendar timestampToCalendar(String timestamp) 

Method Source Code


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

public class Main {
    public static Calendar timestampToCalendar(String timestamp) {
        GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        int year = Integer.parseInt(timestamp.substring(0, 4));
        int month = Integer.parseInt(timestamp.substring(4, 6)) - 1; // January == 0!
        int day = Integer.parseInt(timestamp.substring(6, 8));
        int hour = Integer.parseInt(timestamp.substring(8, 10));
        int minute = Integer.parseInt(timestamp.substring(10, 12));
        int second = Integer.parseInt(timestamp.substring(12, 14));
        calendar.set(year, month, day, hour, minute, second);
        return calendar;
    }//from w ww . j  a  v  a 2 s  .  c om
}

Related

  1. stripTime(final Calendar cal)
  2. stripTimeComponent(Calendar cal)
  3. time2InicioDelDia(Calendar fecha)
  4. timestamp17ToCalendar(String timestamp17String)
  5. timestamp2Calendar(long timestamp)
  6. toDefaultTimeZone(Calendar calendar)
  7. toTimeStamp(Calendar cal)
  8. toTimeString(final Calendar calendar)
  9. toUnixTime(Calendar timestamp)