Here you can find the source of getHourFormat(String string)
public static String getHourFormat(String string)
//package com.java2s; //License from project: LGPL import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static SimpleDateFormat sdf_hour = new SimpleDateFormat("yyyy-MM-dd HH"); public static String getHourFormat(String string) { try {//from w w w .j a v a 2s . co m return sdf_hour.format(sdf_hour.parse(string)); } catch (ParseException e) { return null; } } }