Java Date UTC Format parseCcsdsUtcFormat(String timeString)

Here you can find the source of parseCcsdsUtcFormat(String timeString)

Description

parse Ccsds Utc Format

License

Open Source License

Declaration

public static Date parseCcsdsUtcFormat(String timeString) throws ParseException 

Method Source Code


//package com.java2s;
/*// www . j av a2  s  . c o  m
 * Copyright (c) 2014 Brockmann Consult GmbH (info@brockmann-consult.de)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see http://www.gnu.org/licenses/
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private static final SimpleDateFormat CCSDS_UTC_MILLIS_FORMAT = new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    private static final SimpleDateFormat CCSDS_UTC_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

    public static Date parseCcsdsUtcFormat(String timeString) throws ParseException {
        if (timeString.length() == 20) {
            return CCSDS_UTC_FORMAT.parse(timeString);
        }
        return CCSDS_UTC_MILLIS_FORMAT.parse(timeString);
    }
}

Related

  1. formatUtcDateIfNotNull(final Date date)
  2. formatUtcTime(long tval)
  3. getStrTimeByUTC(long utc, String format)
  4. getUTCDateFormat()
  5. getUTCFormat()
  6. toUTCDateFormat(Date date)
  7. UTCToLocalTime(String UTCFormat, Logger logger)