Java String to Time getSignTime(final String stStr)

Here you can find the source of getSignTime(final String stStr)

Description

get Sign Time

License

Apache License

Declaration

static GregorianCalendar getSignTime(final String stStr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

import java.util.logging.Logger;

public class Main {
    private static final Logger LOGGER = Logger.getLogger("es.gob.afirma");

    static GregorianCalendar getSignTime(final String stStr) {
        if (stStr == null) {
            return new GregorianCalendar();
        }/*from w  w w .  ja  va  2 s  . c om*/

        Date date;
        final SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss"); //$NON-NLS-1$
        try {
            date = formatter.parse(stStr);
        } catch (final Exception e) {
            LOGGER.severe("La fecha indicada ('" + stStr //$NON-NLS-1$
                    + "') como momento de firma para PAdES no sigue el patron 'yyyy:MM:dd:HH:mm:ss': " + e //$NON-NLS-1$
            );
            return new GregorianCalendar();
        }

        // Creamos el calendar a partir de un Date para que tome de el
        final GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(date);

        return calendar;
    }
}

Related

  1. getExecutionDateTime(String input)
  2. getExpireTime(String timeStr)
  3. getFormerDate(String dateTime)
  4. getIdByTime(String name)
  5. getMReportTime(String time)
  6. getStringWithTime(String str)
  7. getSystemTime(String pattern)
  8. getTime(String date)
  9. getTime(String date, String pattern)