Example usage for java.text SimpleDateFormat applyPattern

List of usage examples for java.text SimpleDateFormat applyPattern

Introduction

In this page you can find the example usage for java.text SimpleDateFormat applyPattern.

Prototype

public void applyPattern(String pattern) 

Source Link

Document

Applies the given pattern string to this date format.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat();
    formatter.applyPattern("MMM");

    System.out.println(formatter.clone().equals(new SimpleDateFormat()));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat();
    formatter.applyPattern("MMM");

    System.out.println(formatter.equals(new SimpleDateFormat()));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat();
    formatter.applyPattern("MMM");
    String s = formatter.format(new Date());
    System.out.println(s);//from   ww  w.  j a va2s  .  c o  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat sd = new SimpleDateFormat();
    String dateString = "2015-01-02 14:59:27.953";
    sd.applyPattern("yyyy-MM-dd HH:mm:ss.SSS");
    Date date = sd.parse(dateString);
    sd.applyPattern("MM/dd/yyyy HH:mm a");
    System.out.println(sd.format(date));
}

From source file:Main.java

public static void main(String args[]) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy");
    java.util.Date date = new Date();
    df.applyPattern("EEE");
    String day = df.format(date);
    if (day.compareTo("Sat") == 0 || day.compareTo("Sun") == 0) {
        System.out.println(day + ": Weekend");
    } else {//  www. j a v a 2s .  c  o m
        System.out.println(day + ": Weekday");
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat();
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();

    String era[] = { "BCE", "CE" };
    dfs.setEras(era);//ww  w .  j  av a  2 s . c  om
    sdf.setDateFormatSymbols(dfs);

    sdf.applyPattern("MMMM d yyyy G");
    System.out.println(sdf.format(new Date()));
}

From source file:ChangeEra.java

public static void main(String s[]) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();

    String era[] = { "BCE", "CE" };
    dfs.setEras(era);//w w  w.  j a  v  a 2s.c  o m
    sdf.setDateFormatSymbols(dfs);

    sdf.applyPattern("MMMM d yyyy G");
    System.out.println(sdf.format(new Date()));
}

From source file:Main.java

public static void main(String[] args) {
    SimpleDateFormat simpleFormatter = new SimpleDateFormat("dd/MM/yyyy");
    Date today = new Date();
    String formattedDate = simpleFormatter.format(today);
    System.out.println("Today is (dd/MM/yyyy):  " + formattedDate);

    simpleFormatter.applyPattern("MMMM dd, yyyy");
    formattedDate = simpleFormatter.format(today);
    System.out.println("Today is  (MMMM dd, yyyy): " + formattedDate);
}

From source file:Main.java

public static long parse_iso_time_string_to_long(String iso_time_string) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy-MM-dd'T'HH:mm:ssZ");
    return sdf.parse(iso_time_string).getTime();
}

From source file:Main.java

public static String date_string(long time) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date(time));
}