Java Parse Date Pattern YYYY parseBitcoin(String calendarString)

Here you can find the source of parseBitcoin(String calendarString)

Description

parse Bitcoin

License

Apache License

Declaration

public static Calendar parseBitcoin(String calendarString) 

Method Source Code


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

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    private static DateFormat bitcoinFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    public static Calendar parseBitcoin(String calendarString) {
        try {/*from   w  ww .j a va2s .  c om*/
            Date date = bitcoinFormatter.parse(calendarString);
            Calendar cal = new GregorianCalendar();
            cal.setTime(date);
            return cal;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static Calendar parse(String calendarString) {
        try {
            Date date = getDateFormat().parse(calendarString);
            Calendar cal = new GregorianCalendar();
            cal.setTime(date);
            return cal;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    private static DateFormat getDateFormat() {
        DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
        return formatter;
    }
}

Related

  1. parseArgument(String textDate)
  2. parseAscTime(String date)
  3. parseAsDateTime(String date)
  4. parseAtomDate(String date_str)
  5. parseBingDate(String dateString)
  6. parseCalendar2String(Calendar calendar)
  7. parseCalendarString(String dateTimeString)
  8. parseCDADateFormat(String xsdDate)
  9. parseCompactDate(String exp)