Search in sources :

Example 1 with Format

use of java.text.Format in project GameCore by Warvale.

the class LobbyScoreboard method updateTime.

public void updateTime() {
    for (Player online : Bukkit.getOnlinePlayers()) {
        Objective objective = getScoreboards().get(online.getUniqueId()).getObjective("lobby");
        Team time = getScoreboards().get(online.getUniqueId()).getTeam("LobbyTime");
        if (objective != null && time != null) {
            objective.getScore("    ").setScore(14);
            //objective.getScore("§8» §cTime:").setScore(7);
            Format date = new SimpleDateFormat("HH:mm:ss 'UTC'", Locale.US);
            String dateStr = date.format(new Date());
            time.setSuffix(" §7" + dateStr);
            objective.getScore("§8» §cTime:").setScore(13);
            objective.getScore("   ").setScore(12);
        }
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Player(org.bukkit.entity.Player) Format(java.text.Format) SimpleDateFormat(java.text.SimpleDateFormat) Team(org.bukkit.scoreboard.Team) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with Format

use of java.text.Format in project pcgen by PCGen.

the class Tips method writePOT.

private static void writePOT(Iterable<String> tips, Writer bw) throws IOException {
    // header stuff
    Calendar now = Calendar.getInstance();
    bw.write("msgid \"\"\n" + "msgstr \"\"\n" + "\"Project-Id-Version: PCGen-tips 6.x/SVN?\\n\"\n" + "\"Report-Msgid-Bugs-To: \\n\"\n" + "\"POT-Creation-Date: " + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now) + "\\n\"\n" + "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n" + "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n" + "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n" + "\"MIME-Version: 1.0\\n\"\n" + "\"Content-Type: text/plain; charset=UTF-8\\n\"\n" + "\"Content-Transfer-Encoding: 8bit\\n\"\n\n");
    // filecontent
    //$NON-NLS-1$
    Format msgid = new MessageFormat("msgid \"{0}\"");
    //$NON-NLS-1$
    String msgstr = "msgstr \"\"";
    for (String tip : tips) {
        bw.write(msgid.format(new Object[] { escape(tip) }));
        bw.write("\n");
        bw.write(msgstr);
        bw.write("\n\n");
    }
}
Also used : Format(java.text.Format) MessageFormat(java.text.MessageFormat) MessageFormat(java.text.MessageFormat) Calendar(java.util.Calendar)

Example 3 with Format

use of java.text.Format in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_toFormat_format.

//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
@Test
public void test_toFormat_format() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
Also used : Format(java.text.Format) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 4 with Format

use of java.text.Format in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall.

@Test
public void test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall() throws Exception {
    // SimpleDateFormat throws StringIndexOutOfBoundException
    DateTimeFormatter dtf = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    ParsePosition pos = new ParsePosition(-1);
    Format test = dtf.toFormat();
    assertNull(test.parseObject("ONE30", pos));
    assertTrue(pos.getErrorIndex() >= 0);
}
Also used : Format(java.text.Format) DateTimeFormatter(java.time.format.DateTimeFormatter) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Example 5 with Format

use of java.text.Format in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_toFormat_Query_parseObject_String.

@Test
public void test_toFormat_Query_parseObject_String() throws Exception {
    Format format = DATE_FORMATTER.toFormat(LocalDate::from);
    LocalDate result = (LocalDate) format.parseObject("ONE2012 07 27");
    assertEquals(result, LocalDate.of(2012, 7, 27));
}
Also used : Format(java.text.Format) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

Format (java.text.Format)146 SimpleDateFormat (java.text.SimpleDateFormat)60 DecimalFormat (java.text.DecimalFormat)39 Test (org.junit.Test)38 DateFormat (java.text.DateFormat)34 NumberFormat (java.text.NumberFormat)29 DateTimeFormatter (java.time.format.DateTimeFormatter)27 Date (java.util.Date)26 ChoiceFormat (java.text.ChoiceFormat)24 ParsePosition (java.text.ParsePosition)22 MessageFormat (java.text.MessageFormat)20 FieldPosition (java.text.FieldPosition)16 Test (org.testng.annotations.Test)16 IOException (java.io.IOException)14 ParseException (java.text.ParseException)11 Locale (java.util.Locale)10 AttributedString (java.text.AttributedString)9 ArrayList (java.util.ArrayList)9 TemporalAccessor (java.time.temporal.TemporalAccessor)7 Calendar (java.util.Calendar)7